Class DeviceCodeCredentialBuilder


public class DeviceCodeCredentialBuilder extends AadCredentialBuilderBase<DeviceCodeCredentialBuilder>
Fluent credential builder for instantiating a DeviceCodeCredential.
See Also:
  • Constructor Details

    • DeviceCodeCredentialBuilder

      public DeviceCodeCredentialBuilder()
  • Method Details

    • challengeConsumer

      public DeviceCodeCredentialBuilder challengeConsumer(Consumer<DeviceCodeInfo> 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

      public DeviceCodeCredentialBuilder authenticationRecord(AuthenticationRecord authenticationRecord)
      Sets the AuthenticationRecord 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

      public DeviceCodeCredentialBuilder disableAutomaticAuthentication()
      Disables the automatic authentication and prevents the DeviceCodeCredential from automatically prompting the user. If automatic authentication is disabled a AuthenticationRequiredException will be thrown from DeviceCodeCredential.getToken(TokenRequestContext) in the case that user interaction is necessary. The application is responsible for handling this exception, and calling DeviceCodeCredential.authenticate() or DeviceCodeCredential.authenticate(TokenRequestContext) to authenticate the user interactively.
      Returns:
      An updated instance of this builder with automatic authentication disabled.
    • build

      public DeviceCodeCredential build()
      Creates a new DeviceCodeCredential with the current configurations.
      Returns:
      a DeviceCodeCredential with the current configurations.