Table of Contents

Class JwtHttpHandler

Namespace
Arc4u.Blazor.Handlers
Assembly
Arc4u.OAuth2.Blazor.dll

A DelegatingHandler that adds the token of the current user to the requests of an HttpClient of a Blazor application. The token is requested from the ITokenProvider designated by the ProviderId key of the settings and sent in the Authorization header. Errors are logged and the request is sent without token.

public class JwtHttpHandler : DelegatingHandler, IDisposable
Inheritance
JwtHttpHandler
Implements
Inherited Members

Constructors

JwtHttpHandler(IServiceProvider, ILogger<JwtHttpHandler>, IKeyValueSettings)

A DelegatingHandler that adds the token of the current user to the requests of an HttpClient of a Blazor application. The token is requested from the ITokenProvider designated by the ProviderId key of the settings and sent in the Authorization header. Errors are logged and the request is sent without token.

public JwtHttpHandler(IServiceProvider container, ILogger<JwtHttpHandler> logger, IKeyValueSettings settings)

Parameters

container IServiceProvider

The service provider used to resolve the keyed token provider.

logger ILogger<JwtHttpHandler>

The logger.

settings IKeyValueSettings

The settings designating the token provider.

JwtHttpHandler(IServiceProvider, ILogger<JwtHttpHandler>, string)

Initializes a new instance of the JwtHttpHandler class with the settings registered by name.

public JwtHttpHandler(IServiceProvider container, ILogger<JwtHttpHandler> logger, string resolvingName)

Parameters

container IServiceProvider

The service provider used to resolve the settings and the keyed token provider.

logger ILogger<JwtHttpHandler>

The logger.

resolvingName string

The name of the SimpleKeyValueSettings options designating the token provider.

Exceptions

ConfigurationException

No settings exist with that name.

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

request HttpRequestMessage

The HTTP request message to send to the server.

cancellationToken CancellationToken

A cancellation token to cancel operation.

Returns

Task<HttpResponseMessage>

The task object representing the asynchronous operation.

Exceptions

ArgumentNullException

The request was null.

OperationCanceledException

The cancellation token was canceled. This exception is stored into the returned task.