Table of Contents

Class RefreshTokenProvider

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

The purpose of this token provider is to be used by Oidc one. It will refresh a token based on a refresh token and update the scoped TokenRefreshInfo. The Oidc token provider is responsible to get back an access token.

[Export(typeof(ITokenRefreshProvider))]
public class RefreshTokenProvider : ITokenRefreshProvider
Inheritance
RefreshTokenProvider
Implements
Inherited Members

Constructors

RefreshTokenProvider(TokenRefreshInfo, IOptionsMonitor<OpenIdConnectOptions>, IOptions<OidcAuthenticationOptions>, IActivitySourceFactory, IOptionsMonitor<ApiExtraContextAuthenticationOption>, ILogger<RefreshTokenProvider>)

Initializes a new instance of the RefreshTokenProvider class.

public RefreshTokenProvider(TokenRefreshInfo refreshInfo, IOptionsMonitor<OpenIdConnectOptions> openIdConnectOptions, IOptions<OidcAuthenticationOptions> oidcOptions, IActivitySourceFactory activitySourceFactory, IOptionsMonitor<ApiExtraContextAuthenticationOption> extraContextOptions, ILogger<RefreshTokenProvider> logger)

Parameters

refreshInfo TokenRefreshInfo

The scoped access and refresh tokens of the user, updated by the refresh.

openIdConnectOptions IOptionsMonitor<OpenIdConnectOptions>

The options of the OpenID Connect scheme, giving the client id, the secret and the token endpoint.

oidcOptions IOptions<OidcAuthenticationOptions>

The OpenID Connect authentication options.

activitySourceFactory IActivitySourceFactory

The factory of the activity source used for telemetry.

extraContextOptions IOptionsMonitor<ApiExtraContextAuthenticationOption>

The extra parameters added to the token requests.

logger ILogger<RefreshTokenProvider>

The logger.

Fields

ProviderName

The name (Refresh) of the provider.

public const string ProviderName = "Refresh"

Field Value

string

Methods

RefreshTokenAsync(CancellationToken)

Calls the token endpoint of the authority with the refresh_token grant and stores the new tokens in the scoped TokenRefreshInfo.

public Task<TokenRefreshInfo?> RefreshTokenAsync(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

A token to cancel the operation.

Returns

Task<TokenRefreshInfo>

The updated TokenRefreshInfo.

Exceptions

InvalidOperationException

There is no refresh token, or it is expired.

HttpRequestException

The token endpoint does not answer with a success status code.