Class DeviceCodeCredential

java.lang.Object
com.azure.identity.DeviceCodeCredential
All Implemented Interfaces:
com.azure.core.credential.TokenCredential

public class DeviceCodeCredential extends Object implements com.azure.core.credential.TokenCredential
An AAD credential that acquires a token with a device code for an AAD application.
  • Method Details

    • getToken

      public Mono<com.azure.core.credential.AccessToken> getToken(com.azure.core.credential.TokenRequestContext request)
      Specified by:
      getToken in interface com.azure.core.credential.TokenCredential
    • getTokenSync

      public com.azure.core.credential.AccessToken getTokenSync(com.azure.core.credential.TokenRequestContext request)
      Specified by:
      getTokenSync in interface com.azure.core.credential.TokenCredential
    • authenticate

      public Mono<AuthenticationRecord> authenticate(com.azure.core.credential.TokenRequestContext request)
      Authenticates a user via the device code flow.

      The credential acquires a verification URL and code from the Azure Active Directory. The user must browse to the URL, enter the code, and authenticate with Azure Active Directory. If the user authenticates successfully, the credential receives an access token.

      Parameters:
      request - The details of the authentication request.
      Returns:
      The AuthenticationRecord which can be used to silently authenticate the account on future execution if persistent caching was configured via DeviceCodeCredentialBuilder.tokenCachePersistenceOptions(TokenCachePersistenceOptions) when credential was instantiated.
    • authenticate

      public Mono<AuthenticationRecord> authenticate()
      Authenticates a user via the device code flow.

      The credential acquires a verification URL and code from the Azure Active Directory. The user must browse to the URL, enter the code, and authenticate with Azure Active Directory. If the user authenticates successfully, the credential receives an access token.

      Returns:
      The AuthenticationRecord which can be used to silently authenticate the account on future execution if persistent caching was configured via DeviceCodeCredentialBuilder.tokenCachePersistenceOptions(TokenCachePersistenceOptions) when credential was instantiated.