Skip to main content
Version: 1.13.1

Class: CantonAuthorizationCodeProvider

Defined in: canton/authentication/authorization-code.ts:392

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.

The SDK stays runtime-agnostic: this provider holds 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:409

Creates a provider from an initial token and callbacks.

Parameters

ParameterTypeDescription
configAuthorizationCodeAuthConfigAuthorization code config (used for refresh).
initialTokenAccessTokenThe 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?OAuthRequestOptionsOptional fetch override and abort signal (threaded to refresh).

Returns

AuthorizationCodeProvider

Properties

type

readonly type: "authorizationCode"

Defined in: canton/authentication/authorization-code.ts:393

The auth scheme this provider was built from.

Implementation of

CantonAuthProvider.type

Methods

token()

token(): Promise<AccessToken>

Defined in: canton/authentication/authorization-code.ts:422

Returns a valid access token, refreshing or re-fetching as needed.

Returns

Promise<AccessToken>

Implementation of

CantonAuthProvider.token