Skip to main content
Version: 1.14.0

Function: exchangeCantonAuthorizationCode()

exchangeCantonAuthorizationCode(config: AuthorizationCodeAuthConfig, callback: ValidatedCallback, verifier: string, redirectUri: string, options?: OAuthRequestOptions): Promise<AccessToken>

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

Exchange an authorization code for tokens (access + refresh).

Performs the token endpoint request with the PKCE verifier (RFC 7636) and returns the parsed AccessToken. The embedder should persist the refreshToken so refreshAuthorizationCodeToken can renew the access token without re-running the interactive flow.

Parameters​

ParameterTypeDescription
configAuthorizationCodeAuthConfigAuthorization code config (with authUrl, clientId).
callbackValidatedCallbackThe ValidatedCallback from validateAuthorizationCallback (carries the branded callbackParams).
verifierstringThe PKCE code verifier from buildAuthorizationRequest.
redirectUristringThe redirect URI used in the authorize request.
options?OAuthRequestOptionsOptional fetch override and abort signal.

Returns​

Promise<AccessToken>

The obtained AccessToken (with refreshToken when issued).

Throws​

CCIPError (CANTON_AUTH_ERROR) on token exchange failure.

See​

https://datatracker.ietf.org/doc/html/rfc6749#section-4.1.3