Class UsernamePasswordCredential

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

@Deprecated public class UsernamePasswordCredential extends Object implements com.azure.core.credential.TokenCredential
Deprecated.
This credential is deprecated because it doesn't support multifactor authentication (MFA). See here for details about MFA enforcement for Microsoft Entra ID and migration guidance.

Username password authentication is a common type of authentication flow used by many applications and services, including Microsoft Entra ID. With username password authentication, users enter their username and password credentials to sign in to an application or service. The UsernamePasswordCredential authenticates a public client application and acquires a token using the user credentials that don't require 2FA/MFA (Multi-factored) authentication. For more information refer to the conceptual knowledge and configuration details.

In the scenario where 2FA/MFA (Multi-factored) authentication is turned on, please use DeviceCodeCredential or InteractiveBrowserCredential instead.

See Also:
  • Method Details

    • getToken

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

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

      public Mono<AuthenticationRecord> authenticate(com.azure.core.credential.TokenRequestContext request)
      Deprecated.
      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()
      Deprecated.
      Authenticates the user using the specified username and password.
      Returns:
      The AuthenticationRecord of the authenticated account.