<PackageReference Include="Azure.Core" Version="1.59.0" />

Azure.Core.Pipeline.BearerTokenAuthenticationPolicy

A policy that sends an AccessToken provided by a TokenCredential as an Authorization header.

Event that is triggered when the transport needs to be updated.

public BearerTokenAuthenticationPolicy(TokenCredential credential, string scope)

Creates a new instance of BearerTokenAuthenticationPolicy using provided token credential and scope to authenticate for.

public BearerTokenAuthenticationPolicy(TokenCredential credential, string scope, HttpPipelineTransportOptions transportOptions)

Creates a new instance of BearerTokenAuthenticationPolicy using provided token credential and scope to authenticate for.

public BearerTokenAuthenticationPolicy(TokenCredential credential, IEnumerable<string> scopes)

Creates a new instance of BearerTokenAuthenticationPolicy using provided token credential and scopes to authenticate for.

public BearerTokenAuthenticationPolicy(TokenCredential credential, IEnumerable<string> scopes, HttpPipelineTransportOptions transportOptions)

Creates a new instance of BearerTokenAuthenticationPolicy using provided token credential and scopes to authenticate for.

Sets the Authorization header on the Request by calling GetToken, or from cache, if possible.

Sets the Authorization header on the Request by calling GetToken, or from cache, if possible.

protected virtual void AuthorizeRequest(HttpMessage message)

Executes before ProcessAsync or Process is called. Implementers of this method are expected to call AuthenticateAndAuthorizeRequest or AuthenticateAndAuthorizeRequestAsync if authorization is required for requests not related to handling a challenge response.

protected virtual ValueTask AuthorizeRequestAsync(HttpMessage message)

Executes before ProcessAsync or Process is called. Implementers of this method are expected to call AuthenticateAndAuthorizeRequest or AuthenticateAndAuthorizeRequestAsync if authorization is required for requests not related to handling a challenge response.

protected virtual bool AuthorizeRequestOnChallenge(HttpMessage message)

Executed in the event a 401 response with a WWW-Authenticate authentication challenge header is received after the initial request. The default implementation will attempt to handle Continuous Access Evaluation (CAE) claims challenges.

protected virtual ValueTask<bool> AuthorizeRequestOnChallengeAsync(HttpMessage message)

Executed in the event a 401 response with a WWW-Authenticate authentication challenge header is received after the initial request. The default implementation will attempt to handle Continuous Access Evaluation (CAE) claims challenges.

Triggers the TransportOptionsChanged event to update the transport with new options. This can be used to trigger transport updates when token refreshes happen in the background and new tokens have different requirements for the transport, such as a different client certificate.