Skip to main content
Version: 1.12.0

Class: CantonAuthorizationCodeProvider

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

Authorization code auth provider.

The constructor performs the full interactive flow (browser + callback server) and resolves once tokens are obtained. The resulting 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:97

The auth scheme this provider was built from.

Implementation of

CantonAuthProvider.type

Methods

tokenSource()

tokenSource(): CantonTokenSource

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

Returns the caching token source.

Returns

CantonTokenSource

Implementation of

CantonAuthProvider.tokenSource


fromDirect()

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

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

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:156

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