Skip to main content
Version: 1.13.1

Function: buildCantonAuthorizationRequest()

buildCantonAuthorizationRequest(config: AuthorizationCodeAuthConfig, options?: OAuthRequestOptions & { redirectUri?: string; stateOverride?: string; verifierOverride?: string; }): Promise<AuthorizationRequest>

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

Build the authorization request: authorize URL + PKCE verifier + state.

This is the first step of the interactive flow. The embedder redirects the user's browser to authorizeUrl and retains verifier and state to validate the callback and exchange the code.

Parameters

ParameterTypeDescription
configAuthorizationCodeAuthConfigAuthorization code config (with authUrl, clientId).
options?OAuthRequestOptions & { redirectUri?: string; stateOverride?: string; verifierOverride?: string; }Optional fetch override, abort signal, and overrides for redirectUri, state, and verifier (the latter two for deterministic testing).

Returns

Promise<AuthorizationRequest>

The AuthorizationRequest (authorize URL + PKCE material).

Throws

CCIPError (CANTON_AUTH_ERROR) on discovery failure or invalid config.

Example

TypeScript
const req = await buildAuthorizationRequest({
type: 'authorizationCode',
authUrl: 'https://auth.example.com',
clientId: 'ccip-app',
callbackUrl: 'http://localhost:8400/callback',
})
// Redirect the user to req.authorizeUrl; keep req.verifier + req.state.