Table of Contents

Class DelegateTokenProvider

Namespace
Auth0.ManagementApi
Assembly
Auth0.ManagementApi.dll

An ITokenProvider backed by a user-supplied delegate. Use this to retrieve tokens from an external source such as a secret manager, cache, or any custom async operation. The delegate is invoked on every call; no caching is performed by this class.

public sealed class DelegateTokenProvider : ITokenProvider
Inheritance
DelegateTokenProvider
Implements
Inherited Members
Extension Methods

Constructors

DelegateTokenProvider(Func<CancellationToken, Task<string>>)

Creates a new DelegateTokenProvider with a cancellable async token factory.

public DelegateTokenProvider(Func<CancellationToken, Task<string>> tokenFactory)

Parameters

tokenFactory Func<CancellationToken, Task<string>>

An async function that accepts a CancellationToken and returns a valid access token.

Exceptions

ArgumentNullException

Thrown when tokenFactory is null.

Methods

GetTokenAsync(CancellationToken)

Returns a valid access token, fetching or refreshing as needed.

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

Parameters

cancellationToken CancellationToken

A token to cancel the operation.

Returns

Task<string>