ChainedTokenCredential Class
- java.
lang. Object - com.
azure. identity. ChainedTokenCredential
- com.
Implements
public class ChainedTokenCredential
implements TokenCredential
The ChainedTokenCredential is a convenience credential that allows users to chain together a set of TokenCredential together. The credential executes each credential in the chain sequentially and returns the token from the first credential in the chain that successfully authenticates.
Sample: Construct a ChainedTokenCredential.
The following code sample demonstrates the creation of a ChainedTokenCredential, using the ChainedTokenCredentialBuilder to configure it. The sample below tries silent username+password login tried first, then interactive browser login as needed (e.g. when 2FA is turned on in the directory). Once this credential is created, it may be passed into the builder of many of the Azure SDK for Java client builders as the 'credential' parameter.
TokenCredential usernamePasswordCredential = new UsernamePasswordCredentialBuilder()
.clientId(clientId)
.username(fakeUsernamePlaceholder)
.password(fakePasswordPlaceholder)
.build();
TokenCredential interactiveBrowserCredential = new InteractiveBrowserCredentialBuilder()
.clientId(clientId)
.port(8765)
.build();
TokenCredential credential = new ChainedTokenCredentialBuilder()
.addLast(usernamePasswordCredential)
.addLast(interactiveBrowserCredential)
.build();
Method Summary
Modifier and Type | Method and Description |
---|---|
Mono<Access |
getToken(TokenRequestContext request)
Sequentially calls TokenCredential#getToken(TokenRequestContext) on all the specified credentials, returning the first successfully obtained AccessToken. |
Access |
getTokenSync(TokenRequestContext request) |
Methods inherited from java.lang.Object
Method Details
getToken
public Mono
Sequentially calls TokenCredential#getToken(TokenRequestContext) on all the specified credentials, returning the first successfully obtained AccessToken. 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.
Parameters:
Returns:
getTokenSync
public AccessToken getTokenSync(TokenRequestContext request)
Parameters:
Applies to
Azure SDK for Java
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기