Class AuthorizationCodeCredential
Authenticates by redeeming and authorization code previously obtained from Azure Active Directory. See https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-auth-code-flow for more information about the autorization code authentication flow.
Namespace: Azure.Identity
Assembly: Azure.Identity.dll
Syntax
public class AuthorizationCodeCredential : Azure.Core.TokenCredential
Constructors
AuthorizationCodeCredential()
Protected constructor for mocking.
Declaration
protected AuthorizationCodeCredential ();
AuthorizationCodeCredential(String, String, String, String)
Creates an instance of the ClientSecretCredential with the details needed to authenticate against Azure Active Directory with a prefetched authorization code.
Declaration
public AuthorizationCodeCredential (string tenantId, string clientId, string clientSecret, string authorizationCode);
Parameters
String
tenantId
The Azure Active Directory tenant (directory) Id of the service principal. |
String
clientId
The client (application) ID of the service principal |
String
clientSecret
A client secret that was generated for the App Registration used to authenticate the client. |
String
authorizationCode
The authorization code obtained from a call to authorize. The code should be obtained with all required scopes. See https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-auth-code-flow for more information. |
AuthorizationCodeCredential(String, String, String, String, TokenCredentialOptions)
Creates an instance of the ClientSecretCredential with the details needed to authenticate against Azure Active Directory with a prefetched authorization code.
Declaration
public AuthorizationCodeCredential (string tenantId, string clientId, string clientSecret, string authorizationCode, Azure.Identity.TokenCredentialOptions options);
Parameters
String
tenantId
The Azure Active Directory tenant (directory) Id of the service principal. |
String
clientId
The client (application) ID of the service principal |
String
clientSecret
A client secret that was generated for the App Registration used to authenticate the client. |
String
authorizationCode
The authorization code obtained from a call to authorize. The code should be obtained with all required scopes. See https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-auth-code-flow for more information. |
TokenCredentialOptions
options
Options that allow to configure the management of the requests sent to the Azure Active Directory service. |
Methods
GetToken(TokenRequestContext, CancellationToken)
Obtains a token from the Azure Active Directory service, using the specified authorization code authenticate. 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
An AccessToken which can be used to authenticate service client calls. |
GetTokenAsync(TokenRequestContext, CancellationToken)
Obtains a token from the Azure Active Directory service, using the specified authorization code authenticate. 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>
An AccessToken which can be used to authenticate service client calls. |