Skip to content

Commit c059e59

Browse files
authored
Add exception information for all credential classes (#44633)
1 parent 91186e5 commit c059e59

21 files changed

+118
-26
lines changed

sdk/identity/Azure.Identity/src/Credentials/AuthorizationCodeCredential.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ internal AuthorizationCodeCredential(string tenantId, string clientId, string cl
115115
/// <param name="requestContext">The details of the authentication request.</param>
116116
/// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param>
117117
/// <returns>An <see cref="AccessToken"/> which can be used to authenticate service client calls.</returns>
118+
/// <exception cref="AuthenticationFailedException">Thrown when the authentication failed.</exception>
118119
public override AccessToken GetToken(TokenRequestContext requestContext, CancellationToken cancellationToken = default)
119120
{
120121
return GetTokenImplAsync(false, requestContext, cancellationToken).EnsureCompleted();
@@ -128,6 +129,7 @@ public override AccessToken GetToken(TokenRequestContext requestContext, Cancell
128129
/// <param name="requestContext">The details of the authentication request.</param>
129130
/// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param>
130131
/// <returns>An <see cref="AccessToken"/> which can be used to authenticate service client calls.</returns>
132+
/// <exception cref="AuthenticationFailedException">Thrown when the authentication failed.</exception>
131133
public override async ValueTask<AccessToken> GetTokenAsync(TokenRequestContext requestContext, CancellationToken cancellationToken = default)
132134
{
133135
return await GetTokenImplAsync(true, requestContext, cancellationToken).ConfigureAwait(false);

sdk/identity/Azure.Identity/src/Credentials/AzureApplicationCredential.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ internal AzureApplicationCredential(AzureApplicationCredentialOptions options, E
5151
/// <param name="requestContext">The details of the authentication request.</param>
5252
/// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param>
5353
/// <returns>The first <see cref="AccessToken"/> returned by the specified sources. Any credential which raises a <see cref="CredentialUnavailableException"/> will be skipped.</returns>
54+
/// <exception cref="AuthenticationFailedException">Thrown when the authentication failed.</exception>
5455
public override AccessToken GetToken(TokenRequestContext requestContext, CancellationToken cancellationToken = default)
5556
=> GetTokenImplAsync(false, requestContext, cancellationToken).EnsureCompleted();
5657

@@ -62,6 +63,7 @@ public override AccessToken GetToken(TokenRequestContext requestContext, Cancell
6263
/// <param name="requestContext">The details of the authentication request.</param>
6364
/// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param>
6465
/// <returns>The first <see cref="AccessToken"/> returned by the specified sources. Any credential which raises a <see cref="CredentialUnavailableException"/> will be skipped.</returns>
66+
/// <exception cref="AuthenticationFailedException">Thrown when the authentication failed.</exception>
6567
public override async ValueTask<AccessToken> GetTokenAsync(TokenRequestContext requestContext, CancellationToken cancellationToken = default)
6668
=> await GetTokenImplAsync(true, requestContext, cancellationToken).ConfigureAwait(false);
6769

sdk/identity/Azure.Identity/src/Credentials/AzureCliCredential.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,10 @@ internal AzureCliCredential(CredentialPipeline pipeline, IProcessService process
8484
/// <summary>
8585
/// Obtains a access token from Azure CLI credential, using this access token to authenticate. This method called by Azure SDK clients.
8686
/// </summary>
87-
/// <param name="requestContext"></param>
88-
/// <param name="cancellationToken"></param>
89-
/// <returns></returns>
87+
/// <param name="requestContext">The details of the authentication request.</param>
88+
/// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param>
89+
/// <returns>An <see cref="AccessToken"/> which can be used to authenticate service client calls.</returns>
90+
/// <exception cref="AuthenticationFailedException">Thrown when the authentication failed.</exception>
9091
public override AccessToken GetToken(TokenRequestContext requestContext, CancellationToken cancellationToken = default)
9192
{
9293
return GetTokenImplAsync(false, requestContext, cancellationToken).EnsureCompleted();
@@ -95,9 +96,10 @@ public override AccessToken GetToken(TokenRequestContext requestContext, Cancell
9596
/// <summary>
9697
/// Obtains a access token from Azure CLI service, using the access token to authenticate. This method id called by Azure SDK clients.
9798
/// </summary>
98-
/// <param name="requestContext"></param>
99-
/// <param name="cancellationToken"></param>
100-
/// <returns></returns>
99+
/// <param name="requestContext">The details of the authentication request.</param>
100+
/// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param>
101+
/// <returns>An <see cref="AccessToken"/> which can be used to authenticate service client calls.</returns>
102+
/// <exception cref="AuthenticationFailedException">Thrown when the authentication failed.</exception>
101103
public override async ValueTask<AccessToken> GetTokenAsync(TokenRequestContext requestContext, CancellationToken cancellationToken = default)
102104
{
103105
return await GetTokenImplAsync(true, requestContext, cancellationToken).ConfigureAwait(false);

sdk/identity/Azure.Identity/src/Credentials/AzureDeveloperCliCredential.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,10 @@ internal AzureDeveloperCliCredential(CredentialPipeline pipeline, IProcessServic
7676
/// <summary>
7777
/// Obtains an access token from Azure Developer CLI credential, using this access token to authenticate. This method called by Azure SDK clients.
7878
/// </summary>
79-
/// <param name="requestContext"></param>
80-
/// <param name="cancellationToken"></param>
81-
/// <returns>AccessToken</returns>
79+
/// <param name="requestContext">The details of the authentication request.</param>
80+
/// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param>
81+
/// <returns>An <see cref="AccessToken"/> which can be used to authenticate service client calls.</returns>
82+
/// <exception cref="AuthenticationFailedException">Thrown when the authentication failed.</exception>
8283
public override AccessToken GetToken(TokenRequestContext requestContext, CancellationToken cancellationToken = default)
8384
{
8485
return GetTokenImplAsync(false, requestContext, cancellationToken).EnsureCompleted();
@@ -87,9 +88,10 @@ public override AccessToken GetToken(TokenRequestContext requestContext, Cancell
8788
/// <summary>
8889
/// Obtains an access token from Azure Developer CLI service, using the access token to authenticate. This method is called by Azure SDK clients.
8990
/// </summary>
90-
/// <param name="requestContext"></param>
91-
/// <param name="cancellationToken"></param>
92-
/// <returns></returns>
91+
/// <param name="requestContext">The details of the authentication request.</param>
92+
/// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param>
93+
/// <returns>An <see cref="AccessToken"/> which can be used to authenticate service client calls.</returns>
94+
/// <exception cref="AuthenticationFailedException">Thrown when the authentication failed.</exception>
9395
public override async ValueTask<AccessToken> GetTokenAsync(TokenRequestContext requestContext, CancellationToken cancellationToken = default)
9496
{
9597
return await GetTokenImplAsync(true, requestContext, cancellationToken).ConfigureAwait(false);

sdk/identity/Azure.Identity/src/Credentials/AzurePipelinesCredential.cs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,23 @@ public AzurePipelinesCredential(string tenantId, string clientId, string service
6767
AdditionallyAllowedTenantIds = TenantIdResolver.ResolveAddionallyAllowedTenantIds((options as ISupportsAdditionallyAllowedTenants)?.AdditionallyAllowedTenants);
6868
}
6969

70-
/// <inheritdoc />
70+
/// <summary>
71+
/// Obtains an access token from within an Azure Pipelines environment.
72+
/// </summary>
73+
/// <param name="requestContext">The details of the authentication request.</param>
74+
/// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param>
75+
/// <returns>An <see cref="AccessToken"/> which can be used to authenticate service client calls.</returns>
76+
/// <exception cref="AuthenticationFailedException">Thrown when the authentication failed.</exception>
7177
public override AccessToken GetToken(TokenRequestContext requestContext, CancellationToken cancellationToken)
7278
=> GetTokenCoreAsync(false, requestContext, cancellationToken).EnsureCompleted();
7379

74-
/// <inheritdoc />
80+
/// <summary>
81+
/// Obtains an access token from within an Azure Pipelines environment.
82+
/// </summary>
83+
/// <param name="requestContext">The details of the authentication request.</param>
84+
/// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param>
85+
/// <returns>An <see cref="AccessToken"/> which can be used to authenticate service client calls.</returns>
86+
/// <exception cref="AuthenticationFailedException">Thrown when the authentication failed.</exception>
7587
public override async ValueTask<AccessToken> GetTokenAsync(TokenRequestContext requestContext, CancellationToken cancellationToken)
7688
=> await GetTokenCoreAsync(true, requestContext, cancellationToken).ConfigureAwait(false);
7789

sdk/identity/Azure.Identity/src/Credentials/AzurePowerShellCredential.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,10 @@ internal AzurePowerShellCredential(AzurePowerShellCredentialOptions options, Cre
7676
/// <summary>
7777
/// Obtains a access token from Azure PowerShell, using the access token to authenticate. This method id called by Azure SDK clients.
7878
/// </summary>
79-
/// <param name="requestContext"></param>
80-
/// <param name="cancellationToken"></param>
81-
/// <returns></returns>
79+
/// <param name="requestContext">The details of the authentication request.</param>
80+
/// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param>
81+
/// <returns>An <see cref="AccessToken"/> which can be used to authenticate service client calls.</returns>
82+
/// <exception cref="AuthenticationFailedException">Thrown when the authentication failed.</exception>
8283
public override AccessToken GetToken(TokenRequestContext requestContext, CancellationToken cancellationToken)
8384
{
8485
return GetTokenImplAsync(false, requestContext, cancellationToken).EnsureCompleted();
@@ -87,9 +88,10 @@ public override AccessToken GetToken(TokenRequestContext requestContext, Cancell
8788
/// <summary>
8889
/// Obtains a access token from Azure PowerShell, using the access token to authenticate. This method id called by Azure SDK clients.
8990
/// </summary>
90-
/// <param name="requestContext"></param>
91-
/// <param name="cancellationToken"></param>
92-
/// <returns></returns>
91+
/// <param name="requestContext">The details of the authentication request.</param>
92+
/// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param>
93+
/// <returns>An <see cref="AccessToken"/> which can be used to authenticate service client calls.</returns>
94+
/// <exception cref="AuthenticationFailedException">Thrown when the authentication failed.</exception>
9395
public override async ValueTask<AccessToken> GetTokenAsync(TokenRequestContext requestContext, CancellationToken cancellationToken = default)
9496
{
9597
return await GetTokenImplAsync(true, requestContext, cancellationToken).ConfigureAwait(false);

sdk/identity/Azure.Identity/src/Credentials/ChainedTokenCredential.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ public ChainedTokenCredential(params TokenCredential[] sources)
7676
/// <param name="requestContext">The details of the authentication request.</param>
7777
/// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param>
7878
/// <returns>The first <see cref="AccessToken"/> returned by the specified sources. Any credential which raises a <see cref="CredentialUnavailableException"/> will be skipped.</returns>
79+
/// <exception cref="AuthenticationFailedException">Thrown when the authentication failed.</exception>
7980
public override AccessToken GetToken(TokenRequestContext requestContext, CancellationToken cancellationToken = default)
8081
=> GetTokenImplAsync(false, requestContext, cancellationToken).EnsureCompleted();
8182

@@ -87,6 +88,7 @@ public override AccessToken GetToken(TokenRequestContext requestContext, Cancell
8788
/// <param name="requestContext">The details of the authentication request.</param>
8889
/// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param>
8990
/// <returns>The first <see cref="AccessToken"/> returned by the specified sources. Any credential which raises a <see cref="CredentialUnavailableException"/> will be skipped.</returns>
91+
/// <exception cref="AuthenticationFailedException">Thrown when the authentication failed.</exception>
9092
public override async ValueTask<AccessToken> GetTokenAsync(TokenRequestContext requestContext, CancellationToken cancellationToken = default)
9193
=> await GetTokenImplAsync(true, requestContext, cancellationToken).ConfigureAwait(false);
9294

sdk/identity/Azure.Identity/src/Credentials/ClientAssertionCredential.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ public ClientAssertionCredential(string tenantId, string clientId, Func<string>
7676
/// <param name="requestContext">The details of the authentication request.</param>
7777
/// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param>
7878
/// <returns>An <see cref="AccessToken"/> which can be used to authenticate service client calls.</returns>
79+
/// <exception cref="AuthenticationFailedException">Thrown when the authentication failed.</exception>
7980
public override AccessToken GetToken(TokenRequestContext requestContext, CancellationToken cancellationToken = default)
8081
{
8182
using CredentialDiagnosticScope scope = Pipeline.StartGetTokenScope("ClientAssertionCredential.GetToken", requestContext);
@@ -100,6 +101,7 @@ public override AccessToken GetToken(TokenRequestContext requestContext, Cancell
100101
/// <param name="requestContext">The details of the authentication request.</param>
101102
/// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param>
102103
/// <returns>An <see cref="AccessToken"/> which can be used to authenticate service client calls.</returns>
104+
/// <exception cref="AuthenticationFailedException">Thrown when the authentication failed.</exception>
103105
public async override ValueTask<AccessToken> GetTokenAsync(TokenRequestContext requestContext, CancellationToken cancellationToken = default)
104106
{
105107
using CredentialDiagnosticScope scope = Pipeline.StartGetTokenScope("ClientAssertionCredential.GetToken", requestContext);

sdk/identity/Azure.Identity/src/Credentials/ClientCertificateCredential.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ internal ClientCertificateCredential(
180180
/// <param name="requestContext">The details of the authentication request.</param>
181181
/// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param>
182182
/// <returns>An <see cref="AccessToken"/> which can be used to authenticate service client calls.</returns>
183+
/// <exception cref="AuthenticationFailedException">Thrown when the authentication failed.</exception>
183184
public override AccessToken GetToken(TokenRequestContext requestContext, CancellationToken cancellationToken = default)
184185
{
185186
using CredentialDiagnosticScope scope = _pipeline.StartGetTokenScope("ClientCertificateCredential.GetToken", requestContext);
@@ -205,6 +206,7 @@ public override AccessToken GetToken(TokenRequestContext requestContext, Cancell
205206
/// <param name="requestContext">The details of the authentication request.</param>
206207
/// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param>
207208
/// <returns>An <see cref="AccessToken"/> which can be used to authenticate service client calls.</returns>
209+
/// <exception cref="AuthenticationFailedException">Thrown when the authentication failed.</exception>
208210
public override async ValueTask<AccessToken> GetTokenAsync(TokenRequestContext requestContext, CancellationToken cancellationToken = default)
209211
{
210212
using CredentialDiagnosticScope scope = _pipeline.StartGetTokenScope("ClientCertificateCredential.GetToken", requestContext);

sdk/identity/Azure.Identity/src/Credentials/ClientSecretCredential.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ internal ClientSecretCredential(string tenantId, string clientId, string clientS
109109
/// <param name="requestContext">The details of the authentication request.</param>
110110
/// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param>
111111
/// <returns>An <see cref="AccessToken"/> which can be used to authenticate service client calls.</returns>
112+
/// <exception cref="AuthenticationFailedException">Thrown when the authentication failed.</exception>
112113
public override async ValueTask<AccessToken> GetTokenAsync(TokenRequestContext requestContext, CancellationToken cancellationToken = default)
113114
{
114115
using CredentialDiagnosticScope scope = _pipeline.StartGetTokenScope("ClientSecretCredential.GetToken", requestContext);
@@ -132,6 +133,7 @@ public override async ValueTask<AccessToken> GetTokenAsync(TokenRequestContext r
132133
/// <param name="requestContext">The details of the authentication request.</param>
133134
/// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param>
134135
/// <returns>An <see cref="AccessToken"/> which can be used to authenticate service client calls.</returns>
136+
/// <exception cref="AuthenticationFailedException">Thrown when the authentication failed.</exception>
135137
public override AccessToken GetToken(TokenRequestContext requestContext, CancellationToken cancellationToken = default)
136138
{
137139
using CredentialDiagnosticScope scope = _pipeline.StartGetTokenScope("ClientSecretCredential.GetToken", requestContext);

0 commit comments

Comments
 (0)