Class ClientTokenProvider
- Namespace
- Arc4u.OAuth2.TokenProvider
- Assembly
- Arc4u.OAuth2.Blazor.dll
An ITokenProvider for a Blazor WebAssembly application whose token is given by its server backend. The token is requested with a GET on the
TokenRequestUrl of the settings, through the HttpClient named by HttpClientName (see AddAuthenticationCookie), and kept until it expires.
[Export("Client", typeof(ITokenProvider))]
[Shared]
public class ClientTokenProvider : ISignOutTokenProvider, ITokenProvider
- Inheritance
-
ClientTokenProvider
- Implements
- Inherited Members
Constructors
ClientTokenProvider(IHttpClientFactory, ILogger<ClientTokenProvider>)
An ITokenProvider for a Blazor WebAssembly application whose token is given by its server backend. The token is requested with a GET on the
TokenRequestUrl of the settings, through the HttpClient named by HttpClientName (see AddAuthenticationCookie), and kept until it expires.
public ClientTokenProvider(IHttpClientFactory httpClientFactory, ILogger<ClientTokenProvider> logger)
Parameters
httpClientFactoryIHttpClientFactoryThe factory of the HTTP clients.
loggerILogger<ClientTokenProvider>The logger.
Fields
ProviderName
The key (Client) under which the provider is registered.
public const string ProviderName = "Client"
Field Value
Methods
GetTokenAsync(IKeyValueSettings?, object?)
Gets the token from the server backend, or the previous one when it is still valid.
public ValueTask<Result<TokenInfo>> GetTokenAsync(IKeyValueSettings? settings, object? platformParameters)
Parameters
settingsIKeyValueSettingsThe settings giving
HttpClientNameandTokenRequestUrl.platformParametersobjectNot used.
Returns
- ValueTask<Result<TokenInfo>>
The token, or a failed result when a setting is missing or the token cannot be obtained.
SignOutAsync(IKeyValueSettings, CancellationToken)
Forgets the token kept in memory, so the next call asks the server backend again. Signing out of the backend (its authentication cookie) is done by the application.
public ValueTask SignOutAsync(IKeyValueSettings settings, CancellationToken cancellationToken)
Parameters
settingsIKeyValueSettingsThe provider settings, which are not used.
cancellationTokenCancellationTokenA token to cancel the operation, which is not used.