Class BearerTokenDelegatingHandler<TClient>
- Namespace
- Visus.AddressValidation.Http
- Assembly
- Visus.AddressValidation.dll
An HTTP delegate handler that injects a Bearer token into each request.
public sealed class BearerTokenDelegatingHandler<TClient> : DelegatingHandler, IDisposable where TClient : IAuthenticationClient
Type Parameters
TClient
- Inheritance
-
BearerTokenDelegatingHandler<TClient>
- Implements
- Inherited Members
Constructors
BearerTokenDelegatingHandler(AbstractAuthenticationService<TClient>)
Initializes a new instance of BearerTokenDelegatingHandler<TClient>.
public BearerTokenDelegatingHandler(AbstractAuthenticationService<TClient> authenticationService)
Parameters
authenticationServiceAbstractAuthenticationService<TClient>An instance of AbstractAuthenticationService<TClient> that retrieves the access_token.
Exceptions
- ArgumentNullException
Thrown when
authenticationServiceis null.
Methods
SendAsync(HttpRequestMessage, CancellationToken)
Sends an HTTP request to the inner handler to send to the server as an asynchronous operation.
protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
Parameters
requestHttpRequestMessageThe HTTP request message to send to the server.
cancellationTokenCancellationTokenA cancellation token to cancel operation.
Returns
- Task<HttpResponseMessage>
The task object representing the asynchronous operation.
Exceptions
- ArgumentNullException
The
requestwas null.- OperationCanceledException
The cancellation token was canceled. This exception is stored into the returned task.
- InvalidCredentialException
Provided credentials were rejected by the server.