Package com.azure.identity
Class DeviceCodeCredential
java.lang.Object
com.azure.identity.DeviceCodeCredential
- All Implemented Interfaces:
TokenCredential
An AAD credential that acquires a token with a device code for an AAD application.
-
Method Summary
Modifier and TypeMethodDescriptionAuthenticates a user via the device code flow.authenticate
(TokenRequestContext request) Authenticates a user via the device code flow.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 a user via the device code flow.The credential acquires a verification URL and code from the Azure Active Directory. The user must browse to the URL, enter the code, and authenticate with Azure Active Directory. If the user authenticates successfully, the credential receives an access token.
- Parameters:
request
- The details of the authentication request.- Returns:
- The
AuthenticationRecord
which can be used to silently authenticate the account on future execution if persistent caching was configured viaDeviceCodeCredentialBuilder.tokenCachePersistenceOptions(TokenCachePersistenceOptions)
when credential was instantiated.
-
authenticate
Authenticates a user via the device code flow.The credential acquires a verification URL and code from the Azure Active Directory. The user must browse to the URL, enter the code, and authenticate with Azure Active Directory. If the user authenticates successfully, the credential receives an access token.
- Returns:
- The
AuthenticationRecord
which can be used to silently authenticate the account on future execution if persistent caching was configured viaDeviceCodeCredentialBuilder.tokenCachePersistenceOptions(TokenCachePersistenceOptions)
when credential was instantiated.
-