Function: validateCantonAuthorizationCallback()
validateCantonAuthorizationCallback(
config:AuthorizationCodeAuthConfig,callbackUrl:string|URL,expectedState:string,options?:OAuthRequestOptions):Promise<ValidatedCallback>
Defined in: canton/authentication/authorization-code.ts:261
Validate the authorization callback URL and extract the code + state.
Checks for an OAuth2 error redirect first (e.g. the user denied consent),
then validates the state parameter (CSRF protection) and the presence of a
code via oauth4webapi.validateAuthResponse.
Parameters
| Parameter | Type | Description |
|---|---|---|
config | AuthorizationCodeAuthConfig | Authorization code config (with authUrl, clientId). |
callbackUrl | string | URL | The full redirect URL the browser was sent back to (including ?code=…&state=… or ?error=…). |
expectedState | string | The state value from buildAuthorizationRequest. |
options? | OAuthRequestOptions | Optional fetch override and abort signal. |
Returns
Promise<ValidatedCallback>
The validated ValidatedCallback (code + state).
Throws
CCIPError (CANTON_AUTH_ERROR) on an OAuth2 error redirect, state mismatch, or missing code.
Example
TypeScript
const { code } = await validateAuthorizationCallback(
config, 'http://localhost:8400/callback?code=abc&state=xyz', req.state,
)