Package com.azure.identity
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 Summary
Modifier and TypeMethodDescriptionAuthenticates the user using the specified username and password.authenticate
(com.azure.core.credential.TokenRequestContext request) Authenticates the user using the specified username and password.Mono<com.azure.core.credential.AccessToken>
getToken
(com.azure.core.credential.TokenRequestContext request) com.azure.core.credential.AccessToken
getTokenSync
(com.azure.core.credential.TokenRequestContext request)
-
Method Details
-
getToken
public Mono<com.azure.core.credential.AccessToken> getToken(com.azure.core.credential.TokenRequestContext request) - Specified by:
getToken
in interfacecom.azure.core.credential.TokenCredential
-
getTokenSync
public com.azure.core.credential.AccessToken getTokenSync(com.azure.core.credential.TokenRequestContext request) - Specified by:
getTokenSync
in interfacecom.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
Authenticates the user using the specified username and password.- Returns:
- The
AuthenticationRecord
of the authenticated account.
-