Class: CantonAuthorizationCodeProvider
Defined in: canton/authentication/authorization-code.ts:389
An AuthProvider backed by caller-supplied token-fetch and token-refresh callbacks.
The embedder implements the interactive flow (browser + callback) using
buildAuthorizationRequest, validateAuthorizationCallback,
and exchangeAuthorizationCode, then wraps the resulting token in
this provider. Refresh uses refreshAuthorizationCodeToken when a
refresh token is available; otherwise the initial token is re-fetched
via the fetchToken callback.
This keeps the SDK runtime-agnostic: no callback server or browser logic lives here, only the caching/refresh plumbing an embedder would otherwise have to re-implement.
Implements
Constructors
Constructor
new CantonAuthorizationCodeProvider(
config:AuthorizationCodeAuthConfig,initialToken:AccessToken,fetchToken: () =>Promise<AccessToken>,options?:OAuthRequestOptions):AuthorizationCodeProvider
Defined in: canton/authentication/authorization-code.ts:404
Creates a provider from an initial token and callbacks.
Parameters
| Parameter | Type | Description |
|---|---|---|
config | AuthorizationCodeAuthConfig | Authorization code config (used for refresh). |
initialToken | AccessToken | The token obtained from exchangeAuthorizationCode. |
fetchToken | () => Promise<AccessToken> | Called when the cached token is expired and no refresh callback is supplied (or refresh fails). Must return a fresh token. |
options? | OAuthRequestOptions | Optional fetch override and abort signal (threaded to refresh). |
Returns
AuthorizationCodeProvider
Properties
type
readonlytype:"authorizationCode"
Defined in: canton/authentication/authorization-code.ts:390
The auth scheme this provider was built from.
Implementation of
Methods
getCachedToken()
getCachedToken():
AccessToken|undefined
Defined in: canton/authentication/authorization-code.ts:421
Returns the currently cached token (possibly expired) without fetching.
Returns
AccessToken | undefined
token()
token():
Promise<AccessToken>
Defined in: canton/authentication/authorization-code.ts:416
Returns a valid access token, refreshing or re-fetching as needed.
Returns
Promise<AccessToken>