Function: parseCallbackUrl()
ts
function parseCallbackUrl(url, options): CallbackParams;Defined in: src/core/oauth/parseCallbackUrl.ts:54
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_deniedand no code; stateis 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
| Parameter | Type |
|---|---|
url | string | URL |
options | ParseCallbackUrlOptions |
Returns
Example
typescript
const { code } = parseCallbackUrl(request.url, { expectedState: session.oauthState });
const tokens = await exchangeAuthorizationCode({ clientId, clientSecret, code, redirectUri });
```;