Skip to content

Function: parseCallbackUrl() ​

ts
function parseCallbackUrl(url, options): CallbackParams;

Defined in: src/core/oauth/parseCallbackUrl.ts:54

Stable

Read the authorization code out of the URL Atlassian redirected the user to.

Handles the three ways this step goes wrong, each of which is easy to forget by hand:

  • The user declined on the consent screen, so the URL carries error=access_denied and no code;
  • state is missing or does not match the one you issued;
  • The URL is simply not a callback — no code, no error.

Each throws an OAuthError; for a decline, error is access_denied, which isReauthorizationRequired recognises.

Parameters ​

ParameterType
urlstring | URL
optionsParseCallbackUrlOptions

Returns ​

CallbackParams

Example ​

typescript
  const { code } = parseCallbackUrl(request.url, { expectedState: session.oauthState });

  const tokens = await exchangeAuthorizationCode({ clientId, clientSecret, code, redirectUri });
  ```;