Table of Contents

Class CredentialTokenProvider

Namespace
Arc4u.OAuth2.TokenProvider
Assembly
Arc4u.OAuth2.dll

An ICredentialTokenProvider that requests a token from the token endpoint of an authority with the OAuth2 resource owner password grant. The provider is registered under the name ProviderName. The authority is read from the Authority key of the settings (or the Default authority), the ClientId, optional ClientSecret and Scope (default openid) keys come from the settings too. Failing requests are retried during RetryInterval (90 seconds by default).

[Export("CredentialDirect", typeof(ICredentialTokenProvider))]
[Shared]
public class CredentialTokenProvider : ICredentialTokenProvider
Inheritance
CredentialTokenProvider
Implements
Inherited Members

Constructors

CredentialTokenProvider(ILogger<CredentialTokenProvider>, IOptionsMonitor<AuthorityOptions>)

An ICredentialTokenProvider that requests a token from the token endpoint of an authority with the OAuth2 resource owner password grant. The provider is registered under the name ProviderName. The authority is read from the Authority key of the settings (or the Default authority), the ClientId, optional ClientSecret and Scope (default openid) keys come from the settings too. Failing requests are retried during RetryInterval (90 seconds by default).

public CredentialTokenProvider(ILogger<CredentialTokenProvider> logger, IOptionsMonitor<AuthorityOptions> authorityOptions)

Parameters

logger ILogger<CredentialTokenProvider>

The logger.

authorityOptions IOptionsMonitor<AuthorityOptions>

The named authority options.

Fields

ProviderName

The name (CredentialDirect) under which the provider is registered.

public const string ProviderName = "CredentialDirect"

Field Value

string

Methods

GetTokenAsync(IKeyValueSettings, CredentialsResult)

Requests an access token for the credentials.

public ValueTask<Result<TokenInfo>> GetTokenAsync(IKeyValueSettings settings, CredentialsResult credential)

Parameters

settings IKeyValueSettings

The provider settings (authority, client id, scope...). See TokenKeys.

credential CredentialsResult

The user credentials.

Returns

ValueTask<Result<TokenInfo>>

The token, or a failed result when it cannot be obtained.