Class ClientSecretCredential | Azure SDK for Net
Andrew Vasquez
Published Feb 16, 2026
Inheritance
ClientSecretCredential
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
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. |