Class AbstractBasicAuthenticationClient
- Namespace
- Visus.AddressValidation.Http.Clients
- Assembly
- Visus.AddressValidation.dll
Abstract base class for an authentication client that obtains access tokens using the OAuth 2.0 client credentials grant with HTTP Basic Authentication.
public abstract class AbstractBasicAuthenticationClient : IAuthenticationClient
- Inheritance
-
AbstractBasicAuthenticationClient
- Implements
- Inherited Members
Constructors
AbstractBasicAuthenticationClient(HttpClient)
Initializes a new instance of AbstractBasicAuthenticationClient.
protected AbstractBasicAuthenticationClient(HttpClient httpClient)
Parameters
httpClientHttpClientThe HttpClient used to send token requests.
Exceptions
- ArgumentNullException
Thrown when
httpClientis null.
Properties
Password
Gets the password (client secret or API secret) used for Basic Authentication.
protected abstract string Password { get; }
Property Value
TokenUri
Gets the full URI of the token endpoint.
protected abstract Uri TokenUri { get; }
Property Value
Username
Gets the username (client ID or API key) used for Basic Authentication.
protected abstract string Username { get; }
Property Value
Methods
AddAdditionalHeaders(HttpRequestMessage)
Adds provider-specific headers to the token request. The default implementation is a no-op.
protected virtual void AddAdditionalHeaders(HttpRequestMessage request)
Parameters
requestHttpRequestMessageThe outgoing HttpRequestMessage to augment.
RequestClientCredentialsTokenAsync(CancellationToken)
Sends a token request using the client_credentials grant type.
public Task<TokenResponse?> RequestClientCredentialsTokenAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenA cancellation token that can be used to cancel the work.
Returns
- Task<TokenResponse>
An instance of TokenResponse containing the token or null.