Class OAuthTokenProvider
Provides OAuth 2.0 client credentials authentication. Caches tokens and refreshes them when expired.
public class OAuthTokenProvider : IGraphQlAuthProvider, IDisposable
- Inheritance
-
objectOAuthTokenProvider
- 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
tokenEndpointstringThe OAuth token endpoint URL.
clientIdstringThe client ID.
clientSecretstringThe client secret.
httpClientHttpClientOptional HTTP client instance. When provided, its lifetime is owned by the caller.
loggerFactoryILoggerFactoryOptional 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
cancellationTokenCancellationTokenToken to cancel the operation (e.g. a token-refresh request).