Skip to main content
Version: 1.13.0

Class: CantonAuthorizationCodeProvider

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

Authorization code auth provider.

The constructor performs the full interactive flow (browser + callback server) and resolves once tokens are obtained. The internal CachingTokenSource refreshes via the refresh_token grant when the access token expires.

Implements

Properties

type

readonly type: "authorizationCode"

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

The auth scheme this provider was built from.

Implementation of

CantonAuthProvider.type

Methods

token()

token(): Promise<AccessToken>

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

Returns a valid access token, refreshing via the refresh_token grant if needed.

Returns

Promise<AccessToken>

Implementation of

CantonAuthProvider.token


fromDirect()

static fromDirect(config: AuthorizationCodeAuthConfig & { tokenUrl: string; }, options?: AuthorizationCodeProviderOptions): Promise<AuthorizationCodeProvider>

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

Create a provider with explicit authorization and token endpoint URLs.

Performs the full interactive flow (browser + callback server) and resolves once tokens are obtained. A minimal oauth4webapi.AuthorizationServer is constructed from the provided endpoint URLs.

Parameters

ParameterTypeDescription
configAuthorizationCodeAuthConfig & { tokenUrl: string; }Authorization code config plus a tokenUrl endpoint.
options?AuthorizationCodeProviderOptionsOptional fetch override and stateOverride (for testing).

Returns

Promise<AuthorizationCodeProvider>

A AuthorizationCodeProvider.

Throws

CCIPError (CANTON_AUTH_ERROR) on invalid config or flow errors.


fromDiscovery()

static fromDiscovery(config: AuthorizationCodeAuthConfig, options?: AuthorizationCodeProviderOptions): Promise<AuthorizationCodeProvider>

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

Create a provider using OAuth2 Authorization Server Metadata discovery (RFC 8414) to locate the authorization and token endpoints.

Requires the server to advertise S256 PKCE support.

Parameters

ParameterTypeDescription
configAuthorizationCodeAuthConfigAuthorization code config with authUrl.
options?AuthorizationCodeProviderOptionsOptional fetch override.

Returns

Promise<AuthorizationCodeProvider>

A AuthorizationCodeProvider.

Throws

CCIPError (CANTON_AUTH_ERROR) on discovery failure, missing S256 support, or callback/flow errors.

See

https://datatracker.ietf.org/doc/html/rfc8414