Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add exception information for all credential classes #44633

Merged
merged 5 commits into from
Jul 19, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ internal AuthorizationCodeCredential(string tenantId, string clientId, string cl
/// <param name="requestContext">The details of the authentication request.</param>
/// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param>
/// <returns>An <see cref="AccessToken"/> which can be used to authenticate service client calls.</returns>
/// <exception cref="AuthenticationFailedException">Thrown when the authentication failed.</exception>
/// <exception cref="CredentialUnavailableException">Thrown when the credential is unavailable when used as part of a chained credential such as <see cref="DefaultAzureCredential"/> or <see cref="ChainedTokenCredential"/>.</exception>
public override AccessToken GetToken(TokenRequestContext requestContext, CancellationToken cancellationToken = default)
{
return GetTokenImplAsync(false, requestContext, cancellationToken).EnsureCompleted();
Expand All @@ -128,6 +130,8 @@ public override AccessToken GetToken(TokenRequestContext requestContext, Cancell
/// <param name="requestContext">The details of the authentication request.</param>
/// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param>
/// <returns>An <see cref="AccessToken"/> which can be used to authenticate service client calls.</returns>
/// <exception cref="AuthenticationFailedException">Thrown when the authentication failed.</exception>
/// <exception cref="CredentialUnavailableException">Thrown when the credential is unavailable when used as part of a chained credential such as <see cref="DefaultAzureCredential"/> or <see cref="ChainedTokenCredential"/>.</exception>
public override async ValueTask<AccessToken> GetTokenAsync(TokenRequestContext requestContext, CancellationToken cancellationToken = default)
{
return await GetTokenImplAsync(true, requestContext, cancellationToken).ConfigureAwait(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ internal AzureApplicationCredential(AzureApplicationCredentialOptions options, E
/// <param name="requestContext">The details of the authentication request.</param>
/// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param>
/// <returns>The first <see cref="AccessToken"/> returned by the specified sources. Any credential which raises a <see cref="CredentialUnavailableException"/> will be skipped.</returns>
/// <exception cref="AuthenticationFailedException">Thrown when the authentication failed.</exception>
/// <exception cref="CredentialUnavailableException">Thrown when the credential is unavailable when used as part of a chained credential such as <see cref="DefaultAzureCredential"/> or <see cref="ChainedTokenCredential"/>.</exception>
public override AccessToken GetToken(TokenRequestContext requestContext, CancellationToken cancellationToken = default)
=> GetTokenImplAsync(false, requestContext, cancellationToken).EnsureCompleted();

Expand All @@ -62,6 +64,8 @@ public override AccessToken GetToken(TokenRequestContext requestContext, Cancell
/// <param name="requestContext">The details of the authentication request.</param>
/// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param>
/// <returns>The first <see cref="AccessToken"/> returned by the specified sources. Any credential which raises a <see cref="CredentialUnavailableException"/> will be skipped.</returns>
/// <exception cref="AuthenticationFailedException">Thrown when the authentication failed.</exception>
/// <exception cref="CredentialUnavailableException">Thrown when the credential is unavailable when used as part of a chained credential such as <see cref="DefaultAzureCredential"/> or <see cref="ChainedTokenCredential"/>.</exception>
public override async ValueTask<AccessToken> GetTokenAsync(TokenRequestContext requestContext, CancellationToken cancellationToken = default)
=> await GetTokenImplAsync(true, requestContext, cancellationToken).ConfigureAwait(false);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,11 @@ internal AzureCliCredential(CredentialPipeline pipeline, IProcessService process
/// <summary>
/// Obtains a access token from Azure CLI credential, using this access token to authenticate. This method called by Azure SDK clients.
/// </summary>
/// <param name="requestContext"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
/// <param name="requestContext">The details of the authentication request.</param>
/// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param>
/// <returns>An <see cref="AccessToken"/> which can be used to authenticate service client calls.</returns>
/// <exception cref="AuthenticationFailedException">Thrown when the authentication failed.</exception>
/// <exception cref="CredentialUnavailableException">Thrown when the credential is unavailable when used as part of a chained credential such as <see cref="DefaultAzureCredential"/> or <see cref="ChainedTokenCredential"/>.</exception>
public override AccessToken GetToken(TokenRequestContext requestContext, CancellationToken cancellationToken = default)
{
return GetTokenImplAsync(false, requestContext, cancellationToken).EnsureCompleted();
Expand All @@ -95,9 +97,11 @@ public override AccessToken GetToken(TokenRequestContext requestContext, Cancell
/// <summary>
/// Obtains a access token from Azure CLI service, using the access token to authenticate. This method id called by Azure SDK clients.
/// </summary>
/// <param name="requestContext"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
/// <param name="requestContext">The details of the authentication request.</param>
/// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param>
/// <returns>An <see cref="AccessToken"/> which can be used to authenticate service client calls.</returns>
/// <exception cref="AuthenticationFailedException">Thrown when the authentication failed.</exception>
/// <exception cref="CredentialUnavailableException">Thrown when the credential is unavailable when used as part of a chained credential such as <see cref="DefaultAzureCredential"/> or <see cref="ChainedTokenCredential"/>.</exception>
public override async ValueTask<AccessToken> GetTokenAsync(TokenRequestContext requestContext, CancellationToken cancellationToken = default)
{
return await GetTokenImplAsync(true, requestContext, cancellationToken).ConfigureAwait(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,11 @@ internal AzureDeveloperCliCredential(CredentialPipeline pipeline, IProcessServic
/// <summary>
/// Obtains an access token from Azure Developer CLI credential, using this access token to authenticate. This method called by Azure SDK clients.
/// </summary>
/// <param name="requestContext"></param>
/// <param name="cancellationToken"></param>
/// <returns>AccessToken</returns>
/// <param name="requestContext">The details of the authentication request.</param>
/// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param>
/// <returns>An <see cref="AccessToken"/> which can be used to authenticate service client calls.</returns>
/// <exception cref="AuthenticationFailedException">Thrown when the authentication failed.</exception>
/// <exception cref="CredentialUnavailableException">Thrown when the credential is unavailable when used as part of a chained credential such as <see cref="DefaultAzureCredential"/> or <see cref="ChainedTokenCredential"/>.</exception>
public override AccessToken GetToken(TokenRequestContext requestContext, CancellationToken cancellationToken = default)
{
return GetTokenImplAsync(false, requestContext, cancellationToken).EnsureCompleted();
Expand All @@ -87,9 +89,11 @@ public override AccessToken GetToken(TokenRequestContext requestContext, Cancell
/// <summary>
/// Obtains an access token from Azure Developer CLI service, using the access token to authenticate. This method is called by Azure SDK clients.
/// </summary>
/// <param name="requestContext"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
/// <param name="requestContext">The details of the authentication request.</param>
/// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param>
/// <returns>An <see cref="AccessToken"/> which can be used to authenticate service client calls.</returns>
/// <exception cref="AuthenticationFailedException">Thrown when the authentication failed.</exception>
/// <exception cref="CredentialUnavailableException">Thrown when the credential is unavailable when used as part of a chained credential such as <see cref="DefaultAzureCredential"/> or <see cref="ChainedTokenCredential"/>.</exception>
public override async ValueTask<AccessToken> GetTokenAsync(TokenRequestContext requestContext, CancellationToken cancellationToken = default)
{
return await GetTokenImplAsync(true, requestContext, cancellationToken).ConfigureAwait(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,25 @@ public AzurePipelinesCredential(string tenantId, string clientId, string service
AdditionallyAllowedTenantIds = TenantIdResolver.ResolveAddionallyAllowedTenantIds((options as ISupportsAdditionallyAllowedTenants)?.AdditionallyAllowedTenants);
}

/// <inheritdoc />
/// <summary>
/// Obtains an access token from within an Azure Pipelines environment.
/// </summary>
/// <param name="requestContext">The details of the authentication request.</param>
/// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param>
/// <returns>An <see cref="AccessToken"/> which can be used to authenticate service client calls.</returns>
/// <exception cref="AuthenticationFailedException">Thrown when the authentication failed.</exception>
/// <exception cref="CredentialUnavailableException">Thrown when the credential is unavailable when used as part of a chained credential such as <see cref="DefaultAzureCredential"/> or <see cref="ChainedTokenCredential"/>.</exception>
christothes marked this conversation as resolved.
Show resolved Hide resolved
public override AccessToken GetToken(TokenRequestContext requestContext, CancellationToken cancellationToken)
=> GetTokenCoreAsync(false, requestContext, cancellationToken).EnsureCompleted();

/// <inheritdoc />
/// <summary>
/// Obtains an access token from within an Azure Pipelines environment.
/// </summary>
/// <param name="requestContext">The details of the authentication request.</param>
/// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param>
/// <returns>An <see cref="AccessToken"/> which can be used to authenticate service client calls.</returns>
/// <exception cref="AuthenticationFailedException">Thrown when the authentication failed.</exception>
/// <exception cref="CredentialUnavailableException">Thrown when the credential is unavailable when used as part of a chained credential such as <see cref="DefaultAzureCredential"/> or <see cref="ChainedTokenCredential"/>.</exception>
christothes marked this conversation as resolved.
Show resolved Hide resolved
public override async ValueTask<AccessToken> GetTokenAsync(TokenRequestContext requestContext, CancellationToken cancellationToken)
=> await GetTokenCoreAsync(true, requestContext, cancellationToken).ConfigureAwait(false);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,11 @@ internal AzurePowerShellCredential(AzurePowerShellCredentialOptions options, Cre
/// <summary>
/// Obtains a access token from Azure PowerShell, using the access token to authenticate. This method id called by Azure SDK clients.
/// </summary>
/// <param name="requestContext"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
/// <param name="requestContext">The details of the authentication request.</param>
/// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param>
/// <returns>An <see cref="AccessToken"/> which can be used to authenticate service client calls.</returns>
/// <exception cref="AuthenticationFailedException">Thrown when the authentication failed.</exception>
/// <exception cref="CredentialUnavailableException">Thrown when the credential is unavailable when used as part of a chained credential such as <see cref="DefaultAzureCredential"/> or <see cref="ChainedTokenCredential"/>.</exception>
public override AccessToken GetToken(TokenRequestContext requestContext, CancellationToken cancellationToken)
{
return GetTokenImplAsync(false, requestContext, cancellationToken).EnsureCompleted();
Expand All @@ -87,9 +89,11 @@ public override AccessToken GetToken(TokenRequestContext requestContext, Cancell
/// <summary>
/// Obtains a access token from Azure PowerShell, using the access token to authenticate. This method id called by Azure SDK clients.
/// </summary>
/// <param name="requestContext"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
/// <param name="requestContext">The details of the authentication request.</param>
/// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param>
/// <returns>An <see cref="AccessToken"/> which can be used to authenticate service client calls.</returns>
/// <exception cref="AuthenticationFailedException">Thrown when the authentication failed.</exception>
/// <exception cref="CredentialUnavailableException">Thrown when the credential is unavailable when used as part of a chained credential such as <see cref="DefaultAzureCredential"/> or <see cref="ChainedTokenCredential"/>.</exception>
public override async ValueTask<AccessToken> GetTokenAsync(TokenRequestContext requestContext, CancellationToken cancellationToken = default)
{
return await GetTokenImplAsync(true, requestContext, cancellationToken).ConfigureAwait(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ public ChainedTokenCredential(params TokenCredential[] sources)
/// <param name="requestContext">The details of the authentication request.</param>
/// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param>
/// <returns>The first <see cref="AccessToken"/> returned by the specified sources. Any credential which raises a <see cref="CredentialUnavailableException"/> will be skipped.</returns>
/// <exception cref="AuthenticationFailedException">Thrown when the authentication failed.</exception>
/// <exception cref="CredentialUnavailableException">Thrown when the credential is unavailable when used as part of a chained credential such as <see cref="DefaultAzureCredential"/> or <see cref="ChainedTokenCredential"/>.</exception>
christothes marked this conversation as resolved.
Show resolved Hide resolved
public override AccessToken GetToken(TokenRequestContext requestContext, CancellationToken cancellationToken = default)
=> GetTokenImplAsync(false, requestContext, cancellationToken).EnsureCompleted();

Expand All @@ -87,6 +89,8 @@ public override AccessToken GetToken(TokenRequestContext requestContext, Cancell
/// <param name="requestContext">The details of the authentication request.</param>
/// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param>
/// <returns>The first <see cref="AccessToken"/> returned by the specified sources. Any credential which raises a <see cref="CredentialUnavailableException"/> will be skipped.</returns>
/// <exception cref="AuthenticationFailedException">Thrown when the authentication failed.</exception>
/// <exception cref="CredentialUnavailableException">Thrown when the credential is unavailable when used as part of a chained credential such as <see cref="DefaultAzureCredential"/> or <see cref="ChainedTokenCredential"/>.</exception>
public override async ValueTask<AccessToken> GetTokenAsync(TokenRequestContext requestContext, CancellationToken cancellationToken = default)
=> await GetTokenImplAsync(true, requestContext, cancellationToken).ConfigureAwait(false);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ public ClientAssertionCredential(string tenantId, string clientId, Func<string>
/// <param name="requestContext">The details of the authentication request.</param>
/// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param>
/// <returns>An <see cref="AccessToken"/> which can be used to authenticate service client calls.</returns>
/// <exception cref="AuthenticationFailedException">Thrown when the authentication failed.</exception>
/// <exception cref="CredentialUnavailableException">Thrown when the credential is unavailable when used as part of a chained credential such as <see cref="DefaultAzureCredential"/> or <see cref="ChainedTokenCredential"/>.</exception>
public override AccessToken GetToken(TokenRequestContext requestContext, CancellationToken cancellationToken = default)
{
using CredentialDiagnosticScope scope = Pipeline.StartGetTokenScope("ClientAssertionCredential.GetToken", requestContext);
Expand All @@ -100,6 +102,8 @@ public override AccessToken GetToken(TokenRequestContext requestContext, Cancell
/// <param name="requestContext">The details of the authentication request.</param>
/// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param>
/// <returns>An <see cref="AccessToken"/> which can be used to authenticate service client calls.</returns>
/// <exception cref="AuthenticationFailedException">Thrown when the authentication failed.</exception>
/// <exception cref="CredentialUnavailableException">Thrown when the credential is unavailable when used as part of a chained credential such as <see cref="DefaultAzureCredential"/> or <see cref="ChainedTokenCredential"/>.</exception>
christothes marked this conversation as resolved.
Show resolved Hide resolved
public async override ValueTask<AccessToken> GetTokenAsync(TokenRequestContext requestContext, CancellationToken cancellationToken = default)
{
using CredentialDiagnosticScope scope = Pipeline.StartGetTokenScope("ClientAssertionCredential.GetToken", requestContext);
Expand Down
Loading