Class AbstractClientCredentialsAuthenticationClient
- 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.
public abstract class AbstractClientCredentialsAuthenticationClient : IAuthenticationClient
- Inheritance
-
AbstractClientCredentialsAuthenticationClient
- Implements
- Inherited Members
Constructors
AbstractClientCredentialsAuthenticationClient(HttpClient)
Initializes a new instance of AbstractClientCredentialsAuthenticationClient.
protected AbstractClientCredentialsAuthenticationClient(HttpClient httpClient)
Parameters
httpClientHttpClientThe HttpClient used to send token requests.
Exceptions
- ArgumentNullException
Thrown when
httpClientis null.
Properties
ClientId
Gets the client ID used to authenticate the token request.
protected abstract string ClientId { get; }
Property Value
ClientSecret
Gets the client secret used to authenticate the token request.
protected abstract string ClientSecret { get; }
Property Value
TokenUri
Gets the full URI of the token endpoint.
protected abstract Uri TokenUri { get; }
Property Value
UseHttpBasicAuthentication
Gets a value indicating whether ClientId and ClientSecret are sent as an
Authorization: Basic header. When false, they are sent as client_id and
client_secret form fields in the request body instead. The default implementation returns
false.
protected virtual bool UseHttpBasicAuthentication { get; }
Property Value
Methods
ApplyAdditionalHeaders(HttpRequestMessage)
Applies provider-specific headers to the token request.
protected virtual void ApplyAdditionalHeaders(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.