AsyncBearerTokenCredentialPolicy Class

Adds a bearer token Authorization header to requests.

Inheritance
azure.core.pipeline.policies._base_async.AsyncHTTPPolicy
AsyncBearerTokenCredentialPolicy

Constructor

AsyncBearerTokenCredentialPolicy(credential: AsyncTokenCredential, *scopes: str, **kwargs: Any)

Parameters

credential
TokenCredential
Required

The credential.

scopes
str
Required

Lets you specify the type of access needed.

Methods

authorize_request

Acquire a token from the credential and authorize the request with it.

Keyword arguments are passed to the credential's get_token method. The token will be cached and used to authorize future requests.

on_challenge

Authorize request according to an authentication challenge

This method is called when the resource provider responds 401 with a WWW-Authenticate header.

on_exception

Executed when an exception is raised while executing the next policy.

This method is executed inside the exception handler.

on_request

Adds a bearer token Authorization header to request and sends request to next policy.

on_response

Executed after the request comes back from the next policy.

send

Authorize request with a bearer token and send it to the next policy

authorize_request

Acquire a token from the credential and authorize the request with it.

Keyword arguments are passed to the credential's get_token method. The token will be cached and used to authorize future requests.

async authorize_request(request: PipelineRequest, *scopes: str, **kwargs: Any) -> None

Parameters

request
PipelineRequest
Required

the request

scopes
str
Required

required scopes of authentication

on_challenge

Authorize request according to an authentication challenge

This method is called when the resource provider responds 401 with a WWW-Authenticate header.

async on_challenge(request: PipelineRequest, response: PipelineResponse) -> bool

Parameters

request
PipelineRequest
Required

the request which elicited an authentication challenge

response
PipelineResponse
Required

the resource provider's response

Returns

a bool indicating whether the policy should send the request

on_exception

Executed when an exception is raised while executing the next policy.

This method is executed inside the exception handler.

on_exception(request: PipelineRequest) -> None

Parameters

request
PipelineRequest
Required

The Pipeline request object

on_request

Adds a bearer token Authorization header to request and sends request to next policy.

async on_request(request: PipelineRequest) -> None

Parameters

request
PipelineRequest
Required

The pipeline request object to be modified.

Exceptions

on_response

Executed after the request comes back from the next policy.

on_response(request: PipelineRequest, response: PipelineResponse) -> Union[None, Awaitable[None]]

Parameters

request
PipelineRequest
Required

Request to be modified after returning from the policy.

response
PipelineResponse
Required

Pipeline response object

send

Authorize request with a bearer token and send it to the next policy

async send(request: PipelineRequest) -> PipelineResponse

Parameters

request
PipelineRequest
Required

The pipeline request object