Package com.azure.core.http.policy
Class BearerTokenAuthenticationPolicy
java.lang.Object
com.azure.core.http.policy.BearerTokenAuthenticationPolicy
- All Implemented Interfaces:
HttpPipelinePolicy
The pipeline policy that applies a token credential to an HTTP request
with "Bearer" scheme.
-
Constructor Summary
ConstructorsConstructorDescriptionBearerTokenAuthenticationPolicy(TokenCredential credential, String... scopes) Creates BearerTokenAuthenticationPolicy. -
Method Summary
Modifier and TypeMethodDescriptionauthorizeRequest(HttpPipelineCallContext context) Executed before sending the initial request and authenticates the request.authorizeRequestOnChallenge(HttpPipelineCallContext context, HttpResponse response) Handles the authentication challenge in the event a 401 response with a WWW-Authenticate authentication challenge header is received after the initial request and returns appropriateTokenRequestContextto be used for re-authentication.process(HttpPipelineCallContext context, HttpPipelineNextPolicy next) Processes provided request context and invokes the next policy.setAuthorizationHeader(HttpPipelineCallContext context, TokenRequestContext tokenRequestContext) Authorizes the request with the bearer token acquired using the specifiedtokenRequestContextMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.azure.core.http.policy.HttpPipelinePolicy
getPipelinePosition
-
Constructor Details
-
BearerTokenAuthenticationPolicy
Creates BearerTokenAuthenticationPolicy.- Parameters:
credential- the token credential to authenticate the requestscopes- the scopes of authentication the credential should get token for
-
-
Method Details
-
authorizeRequest
Executed before sending the initial request and authenticates the request. -
authorizeRequestOnChallenge
public Mono<Boolean> authorizeRequestOnChallenge(HttpPipelineCallContext context, HttpResponse response) Handles the authentication challenge in the event a 401 response with a WWW-Authenticate authentication challenge header is received after the initial request and returns appropriateTokenRequestContextto be used for re-authentication.- Parameters:
context- The request context.response- The Http Response containing the authentication challenge header.- Returns:
- A
MonocontainingTokenRequestContext
-
process
Description copied from interface:HttpPipelinePolicyProcesses provided request context and invokes the next policy.- Specified by:
processin interfaceHttpPipelinePolicy- Parameters:
context- The request context.next- The next policy to invoke.- Returns:
- A publisher that initiates the request upon subscription and emits a response on completion.
-
setAuthorizationHeader
public Mono<Void> setAuthorizationHeader(HttpPipelineCallContext context, TokenRequestContext tokenRequestContext) Authorizes the request with the bearer token acquired using the specifiedtokenRequestContext
-