Table of Contents

Class OidcTokenProvider

Namespace
Arc4u.OAuth2.TokenProviders
Assembly
Arc4u.OAuth2.AspNetCore.Authentication.dll

An ITokenProvider that returns the access token of a user authenticated with OpenID Connect and the cookie scheme. The token comes from the scoped TokenRefreshInfo; when it expires in less than ForceRefreshTimeoutTimeSpan, it is refreshed with the refresh token first.

[Export("Oidc", typeof(ITokenProvider))]
public class OidcTokenProvider : ITokenProvider
Inheritance
OidcTokenProvider
Implements
Inherited Members

Constructors

OidcTokenProvider(ILogger<OidcTokenProvider>, TokenRefreshInfo, IOptions<OidcAuthenticationOptions>, ITokenRefreshProvider)

Initializes a new instance of the OidcTokenProvider class.

public OidcTokenProvider(ILogger<OidcTokenProvider> logger, TokenRefreshInfo tokenRefreshInfo, IOptions<OidcAuthenticationOptions> oidcOptions, ITokenRefreshProvider refreshTokenProvider)

Parameters

logger ILogger<OidcTokenProvider>

The logger.

tokenRefreshInfo TokenRefreshInfo

The scoped access and refresh tokens of the user.

oidcOptions IOptions<OidcAuthenticationOptions>

The OpenID Connect authentication options.

refreshTokenProvider ITokenRefreshProvider

The provider that refreshes the tokens.

Fields

ProviderName

The key (Oidc) under which the provider is registered.

public const string ProviderName = "Oidc"

Field Value

string

Methods

GetTokenAsync(IKeyValueSettings?, object?)

Gets the access token of the user, refreshing it when it is about to expire.

public ValueTask<Result<TokenInfo>> GetTokenAsync(IKeyValueSettings? settings, object? platformParameters)

Parameters

settings IKeyValueSettings

The provider settings, which must not be null.

platformParameters object

Not used.

Returns

ValueTask<Result<TokenInfo>>

The access token, or a failed result when the user is not logged in (no access and no refresh token).

Exceptions

ArgumentNullException

settings is null.