Class DefaultAzureCredential
Provides a default TokenCredential authentication flow for applications that will be deployed to Azure. The following credential types if enabled will be tried, in order:
Consult the documentation of these credential types for more information on how they attempt authentication.Namespace: Azure.Identity
Assembly: Azure.Identity.dll
Syntax
public class DefaultAzureCredential : Azure.Core.TokenCredential
Remarks
Note that credentials requiring user interaction, such as the InteractiveBrowserCredential, are not included by default. Callers must explicitly enable this when constructing the DefaultAzureCredential either by setting the includeInteractiveCredentials parameter to true, or the setting the ExcludeInteractiveBrowserCredential property to false when passing DefaultAzureCredentialOptions.
Constructors
DefaultAzureCredential(DefaultAzureCredentialOptions)
Creates an instance of the DefaultAzureCredential class.
Declaration
public DefaultAzureCredential (Azure.Identity.DefaultAzureCredentialOptions options);
Parameters
DefaultAzureCredentialOptions
options
Options that configure the management of the requests sent to Azure Active Directory services, and determine which credentials are included in the DefaultAzureCredential authentication flow. |
DefaultAzureCredential(Boolean)
Creates an instance of the DefaultAzureCredential class.
Declaration
public DefaultAzureCredential (bool includeInteractiveCredentials = false);
Parameters
Boolean
includeInteractiveCredentials
Specifies whether credentials requiring user interaction will be included in the default authentication flow. |
Methods
GetToken(TokenRequestContext, CancellationToken)
Sequentially calls Azure.Core.TokenCredential.GetToken(Azure.Core.TokenRequestContext,System.Threading.CancellationToken) on all the included credentials in the order EnvironmentCredential, ManagedIdentityCredential, SharedTokenCacheCredential, and InteractiveBrowserCredential returning the first successfully obtained AccessToken. This method is called by Azure SDK clients. It isn't intended for use in application code.
Declaration
public override Azure.Core.AccessToken GetToken (Azure.Core.TokenRequestContext requestContext, System.Threading.CancellationToken cancellationToken = null);
Parameters
Azure.Core.TokenRequestContext
requestContext
The details of the authentication request. |
CancellationToken
cancellationToken
A CancellationToken controlling the request lifetime. |
Returns
AccessToken
The first AccessToken returned by the specified sources. Any credential which raises a CredentialUnavailableException will be skipped. |
Remarks
Note that credentials requiring user interaction, such as the InteractiveBrowserCredential, are not included by default.
GetTokenAsync(TokenRequestContext, CancellationToken)
Sequentially calls Azure.Core.TokenCredential.GetToken(Azure.Core.TokenRequestContext,System.Threading.CancellationToken) on all the included credentials in the order EnvironmentCredential, ManagedIdentityCredential, SharedTokenCacheCredential, and InteractiveBrowserCredential returning the first successfully obtained AccessToken. This method is called by Azure SDK clients. It isn't intended for use in application code.
Declaration
[System.Diagnostics.DebuggerStepThrough]
public override System.Threading.Tasks.ValueTask<Azure.Core.AccessToken> GetTokenAsync (Azure.Core.TokenRequestContext requestContext, System.Threading.CancellationToken cancellationToken = null);
Parameters
Azure.Core.TokenRequestContext
requestContext
The details of the authentication request. |
CancellationToken
cancellationToken
A CancellationToken controlling the request lifetime. |
Returns
ValueTask<AccessToken>
The first AccessToken returned by the specified sources. Any credential which raises a CredentialUnavailableException will be skipped. |
Remarks
Note that credentials requiring user interaction, such as the InteractiveBrowserCredential, are not included by default.