Table of Contents

Class OAuthTokenProvider

Namespace
BpNexT.NET.GraphQL.Client.OAuth
Assembly
BpNexT.NET.GraphQL.dll

Provides OAuth 2.0 client credentials authentication. Caches tokens and refreshes them when expired.

public class OAuthTokenProvider : IGraphQlAuthProvider, IDisposable
Inheritance
object
OAuthTokenProvider
Implements

Constructors

OAuthTokenProvider(string, string, string, HttpClient?, ILoggerFactory?)

Initializes a new instance of the OAuthTokenProvider class.

public OAuthTokenProvider(string tokenEndpoint, string clientId, string clientSecret, HttpClient? httpClient = null, ILoggerFactory? loggerFactory = null)

Parameters

tokenEndpoint string

The OAuth token endpoint URL.

clientId string

The client ID.

clientSecret string

The client secret.

httpClient HttpClient

Optional HTTP client instance. When provided, its lifetime is owned by the caller.

loggerFactory ILoggerFactory

Optional logger factory. If null, SDK logging is disabled for this provider.

Methods

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

GetTokenAsync(CancellationToken)

Returns the current bearer token.

public Task<string> GetTokenAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Token to cancel the operation (e.g. a token-refresh request).

Returns

Task<string>