Package com.azure.identity
Class DeviceCodeCredentialBuilder
java.lang.Object
com.azure.identity.CredentialBuilderBase<T>
com.azure.identity.AadCredentialBuilderBase<DeviceCodeCredentialBuilder>
com.azure.identity.DeviceCodeCredentialBuilder
public class DeviceCodeCredentialBuilder
extends AadCredentialBuilderBase<DeviceCodeCredentialBuilder>
Fluent credential builder for instantiating a
DeviceCodeCredential
.- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionadditionallyAllowedTenants
(String... additionallyAllowedTenants) For multi-tenant applications, specifies additional tenants for which the credential may acquire tokens.additionallyAllowedTenants
(List<String> additionallyAllowedTenants) For multi-tenant applications, specifies additional tenants for which the credential may acquire tokens.authenticationRecord
(AuthenticationRecord authenticationRecord) Sets theAuthenticationRecord
captured from a previous authentication.build()
Creates a newDeviceCodeCredential
with the current configurations.challengeConsumer
(Consumer<DeviceCodeInfo> challengeConsumer) Sets the consumer to meet the device code challenge.Disables the automatic authentication and prevents theDeviceCodeCredential
from automatically prompting the user.tokenCachePersistenceOptions
(TokenCachePersistenceOptions tokenCachePersistenceOptions) Configures the persistent shared token cache options and enables the persistent token cache which is disabled by default.Methods inherited from class com.azure.identity.AadCredentialBuilderBase
authorityHost, clientId, executorService, tenantId
Methods inherited from class com.azure.identity.CredentialBuilderBase
configuration, enableAccountIdentifierLogging, httpClient, httpPipeline, maxRetry, proxyOptions, retryTimeout
-
Constructor Details
-
DeviceCodeCredentialBuilder
public DeviceCodeCredentialBuilder()
-
-
Method Details
-
challengeConsumer
Sets the consumer to meet the device code challenge. If not specified a default consumer is used which prints the device code info message to stdout.- Parameters:
challengeConsumer
- A method allowing the user to meet the device code challenge.- Returns:
- the InteractiveBrowserCredentialBuilder itself
-
tokenCachePersistenceOptions
public DeviceCodeCredentialBuilder tokenCachePersistenceOptions(TokenCachePersistenceOptions tokenCachePersistenceOptions) Configures the persistent shared token cache options and enables the persistent token cache which is disabled by default. If configured, the credential will store tokens in a cache persisted to the machine, protected to the current user, which can be shared by other credentials and processes.- Parameters:
tokenCachePersistenceOptions
- the token cache configuration options- Returns:
- An updated instance of this builder with the token cache options configured.
-
authenticationRecord
Sets theAuthenticationRecord
captured from a previous authentication.- Parameters:
authenticationRecord
- the authentication record to be configured.- Returns:
- An updated instance of this builder with the configured authentication record.
-
disableAutomaticAuthentication
Disables the automatic authentication and prevents theDeviceCodeCredential
from automatically prompting the user. If automatic authentication is disabled aAuthenticationRequiredException
will be thrown fromDeviceCodeCredential.getToken(TokenRequestContext)
in the case that user interaction is necessary. The application is responsible for handling this exception, and callingDeviceCodeCredential.authenticate()
orDeviceCodeCredential.authenticate(TokenRequestContext)
to authenticate the user interactively.- Returns:
- An updated instance of this builder with automatic authentication disabled.
-
additionallyAllowedTenants
For multi-tenant applications, specifies additional tenants for which the credential may acquire tokens. Add the wildcard value "*" to allow the credential to acquire tokens for any tenant on which the application is installed. If no value is specified for TenantId this option will have no effect, and the credential will acquire tokens for any requested tenant.- Overrides:
additionallyAllowedTenants
in classAadCredentialBuilderBase<DeviceCodeCredentialBuilder>
- Parameters:
additionallyAllowedTenants
- the additionally allowed tenants.- Returns:
- An updated instance of this builder with the additional tenants configured.
-
additionallyAllowedTenants
public DeviceCodeCredentialBuilder additionallyAllowedTenants(List<String> additionallyAllowedTenants) For multi-tenant applications, specifies additional tenants for which the credential may acquire tokens. Add the wildcard value "*" to allow the credential to acquire tokens for any tenant on which the application is installed. If no value is specified for TenantId this option will have no effect, and the credential will acquire tokens for any requested tenant.- Overrides:
additionallyAllowedTenants
in classAadCredentialBuilderBase<DeviceCodeCredentialBuilder>
- Parameters:
additionallyAllowedTenants
- the additionally allowed tenants.- Returns:
- An updated instance of this builder with the additional tenants configured.
-
build
Creates a newDeviceCodeCredential
with the current configurations.- Returns:
- a
DeviceCodeCredential
with the current configurations.
-