Class ClientSecretCredential
Enables authentication to Azure Active Directory using a client secret that was generated for an App Registration. More information on how to configure a client secret can be found here: https://docs.microsoft.com/en-us/azure/active-directory/develop/quickstart-configure-app-access-web-apis#add-credentials-to-your-web-application
Namespace: Azure.Identity
Assembly: Azure.Identity.dll
Syntax
public class ClientSecretCredential : Azure.Core.TokenCredential
Constructors
ClientSecretCredential()
Protected constructor for mocking.
Declaration
protected ClientSecretCredential ();
ClientSecretCredential(String, String, String)
Creates an instance of the ClientSecretCredential with the details needed to authenticate against Azure Active Directory with a client secret.
Declaration
public ClientSecretCredential (string tenantId, string clientId, string clientSecret);
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. |
ClientSecretCredential(String, String, String, TokenCredentialOptions)
Creates an instance of the ClientSecretCredential with the details needed to authenticate against Azure Active Directory with a client secret.
Declaration
public ClientSecretCredential (string tenantId, string clientId, string clientSecret, 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. |
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 client secret to 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 client secret to 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. |