Class UsernamePasswordCredential

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

public class UsernamePasswordCredential extends Object implements com.azure.core.credential.TokenCredential
An AAD credential that acquires a token with a username and a password. Users with 2FA/MFA (Multi-factored auth) turned on will not be able to use this credential. Please use DeviceCodeCredential or InteractiveBrowserCredential instead, or create a service principal if you want to authenticate silently.
  • 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 the user using the specified username and password.
      Parameters:
      request - The details of the authentication request.
      Returns:
      The AuthenticationRecord of the authenticated account.
    • authenticate

      public Mono<AuthenticationRecord> authenticate()
      Authenticates the user using the specified username and password.
      Returns:
      The AuthenticationRecord of the authenticated account.