Class ClientSecretCredential

java.lang.Object
com.azure.identity.ClientSecretCredential
All Implemented Interfaces:
TokenCredential

public class ClientSecretCredential extends Object implements TokenCredential
An AAD credential that acquires a token with a client secret for an AAD application.

Sample: Construct a simple ClientSecretCredential

 ClientSecretCredential credential1 = new ClientSecretCredentialBuilder()
     .tenantId(tenantId)
     .clientId(clientId)
     .clientSecret(clientSecret)
     .build();
 

Sample: Construct a ClientSecretCredential behind a proxy

 ClientSecretCredential credential2 = new ClientSecretCredentialBuilder()
     .tenantId(tenantId)
     .clientId(clientId)
     .clientSecret(clientSecret)
     .proxyOptions(new ProxyOptions(Type.HTTP, new InetSocketAddress("10.21.32.43", 5465)))
     .build();
 
  • Method Details

    • getToken

      public Mono<AccessToken> getToken(TokenRequestContext request)
      Description copied from interface: TokenCredential
      Asynchronously get a token for a given resource/audience. This method is called automatically by Azure SDK client libraries. You may call this method directly, but you must also handle token caching and token refreshing.
      Specified by:
      getToken in interface TokenCredential
      Parameters:
      request - the details of the token request
      Returns:
      a Publisher that emits a single access token