Class RefreshableToken
- Namespace
- OpenShell
- Assembly
- OpenShell.Sdk.dll
Caches an access token and renews it single-flight, proactively before expiry and reactively after the gateway rejects it.
public sealed class RefreshableToken : IDisposable
- Inheritance
-
RefreshableToken
- Implements
- Inherited Members
Constructors
RefreshableToken(AccessToken, TokenRefresher, TimeSpan?, TimeProvider?)
Creates a refreshable token starting from initial.
public RefreshableToken(AccessToken initial, TokenRefresher refresher, TimeSpan? leeway = null, TimeProvider? timeProvider = null)
Parameters
initialAccessTokenrefresherTokenRefresherleewayTimeSpan?timeProviderTimeProvider
Methods
AsAuthProvider()
Exposes this token as an IAuthProvider that recovers from Unauthenticated.
public IAuthProvider AsAuthProvider()
Returns
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
GetAsync(CancellationToken)
Returns a valid token, refreshing first when it is expired or about to expire.
public ValueTask<string> GetAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationToken
Returns
RefreshNowAsync(CancellationToken)
Forces a refresh unless another caller already replaced the rejected token. Returns true when a different token is now in place.
public ValueTask<bool> RefreshNowAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationToken