Class BearerTokenAuthenticationChallengePolicy
- java.lang.Object
-
- com.azure.core.experimental.http.policy.BearerTokenAuthenticationChallengePolicy
-
- All Implemented Interfaces:
HttpPipelinePolicy
public class BearerTokenAuthenticationChallengePolicy extends Object implements HttpPipelinePolicy
The pipeline policy that applies a token credential to an HTTP request with "Bearer" scheme.
-
-
Constructor Summary
Constructors Constructor Description BearerTokenAuthenticationChallengePolicy(TokenCredential credential, String... scopes)
Creates BearerTokenAuthenticationChallengePolicy.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Mono<Void>
authorizeRequest(HttpPipelineCallContext context)
Executed before sending the initial request and authenticates the request.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 appropriateTokenRequestContext
to be used for re-authentication.Mono<HttpResponse>
process(HttpPipelineCallContext context, HttpPipelineNextPolicy next)
Mono<Void>
setAuthorizationHeader(HttpPipelineCallContext context, TokenRequestContext tokenRequestContext)
Authorizes the request with the bearer token acquired using the specifiedtokenRequestContext
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.azure.core.http.policy.HttpPipelinePolicy
getPipelinePosition
-
-
-
-
Constructor Detail
-
BearerTokenAuthenticationChallengePolicy
public BearerTokenAuthenticationChallengePolicy(TokenCredential credential, String... scopes)
Creates BearerTokenAuthenticationChallengePolicy.- Parameters:
credential
- the token credential to authenticate the requestscopes
- the scopes required for the token
-
-
Method Detail
-
authorizeRequest
public Mono<Void> authorizeRequest(HttpPipelineCallContext context)
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 appropriateTokenRequestContext
to be used for re-authentication.- Parameters:
context
- The request context.response
- The Http Response containing the authentication challenge header.- Returns:
- A
Mono
containingTokenRequestContext
-
process
public Mono<HttpResponse> process(HttpPipelineCallContext context, HttpPipelineNextPolicy next)
- Specified by:
process
in interfaceHttpPipelinePolicy
-
setAuthorizationHeader
public Mono<Void> setAuthorizationHeader(HttpPipelineCallContext context, TokenRequestContext tokenRequestContext)
Authorizes the request with the bearer token acquired using the specifiedtokenRequestContext
-
-