Table of Contents

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

httpClient HttpClient

The HttpClient used to send token requests.

Exceptions

ArgumentNullException

Thrown when httpClient is null.

Properties

ClientId

Gets the client ID used to authenticate the token request.

protected abstract string ClientId { get; }

Property Value

string

ClientSecret

Gets the client secret used to authenticate the token request.

protected abstract string ClientSecret { get; }

Property Value

string

TokenUri

Gets the full URI of the token endpoint.

protected abstract Uri TokenUri { get; }

Property Value

Uri

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

bool

Methods

ApplyAdditionalHeaders(HttpRequestMessage)

Applies provider-specific headers to the token request.

protected virtual void ApplyAdditionalHeaders(HttpRequestMessage request)

Parameters

request HttpRequestMessage

The outgoing HttpRequestMessage to augment.

RequestClientCredentialsTokenAsync(CancellationToken)

Sends a token request using the client_credentials grant type.

public Task<TokenResponse?> RequestClientCredentialsTokenAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

A cancellation token that can be used to cancel the work.

Returns

Task<TokenResponse>

An instance of TokenResponse containing the token or null.