Class ChainedTokenCredential

java.lang.Object
com.azure.identity.ChainedTokenCredential
All Implemented Interfaces:
TokenCredential
Direct Known Subclasses:
DefaultAzureCredential

public class ChainedTokenCredential extends Object implements TokenCredential
A token credential provider that can provide a credential from a list of providers.

Sample: Construct a ChainedTokenCredential with silent username+password login tried first, then interactive browser login as needed (e.g. when 2FA is turned on in the directory).

 UsernamePasswordCredential usernamePasswordCredential = new UsernamePasswordCredentialBuilder()
     .clientId(clientId)
     .username(username)
     .password(password)
     .build();
 InteractiveBrowserCredential interactiveBrowserCredential = new InteractiveBrowserCredentialBuilder()
     .clientId(clientId)
     .port(8765)
     .build();
 ChainedTokenCredential credential = new ChainedTokenCredentialBuilder()
     .addLast(usernamePasswordCredential)
     .addLast(interactiveBrowserCredential)
     .build();
 
  • Method Details