Package com.azure.identity
Class UsernamePasswordCredential
java.lang.Object
com.azure.identity.UsernamePasswordCredential
- All Implemented Interfaces:
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
(TokenRequestContext request) Authenticates the user using the specified username and password.getToken
(TokenRequestContext request) Asynchronously get a token for a given resource/audience.
-
Method Details
-
getToken
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 interfaceTokenCredential
- Parameters:
request
- the details of the token request- Returns:
- a Publisher that emits a single access token
-
authenticate
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.
-