Class UsernamePasswordCredential

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

public class UsernamePasswordCredential extends Object implements 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<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
    • authenticate

      public Mono<AuthenticationRecord> authenticate(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.