TokenSource

class TokenSource(provider: OAuthProvider, store: TokenStore, client: OAuthClient = OAuthClient(), now: () -> Long = System::currentTimeMillis, refreshUrlOverride: String? = null)(source)

Hands out a usable access token, refreshing it when it's about to expire. Refreshes are single-flight: concurrent callers wait for one refresh instead of racing (providers that rotate refresh tokens would otherwise invalidate each other's).

Constructors

Link copied to clipboard
constructor(provider: OAuthProvider, store: TokenStore, client: OAuthClient = OAuthClient(), now: () -> Long = System::currentTimeMillis, refreshUrlOverride: String? = null)

Properties

Link copied to clipboard

Functions

Link copied to clipboard
suspend fun fresh(forceRefresh: Boolean = false): OAuthTokens

A token valid now; forceRefresh after the API rejected the current one.