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:
error=access_denied
state
Each throws an OAuthError; for a decline, error is access_denied, which isReauthorizationRequired recognises.
error
access_denied
const { code } = parseCallbackUrl(request.url, { expectedState: session.oauthState }); const tokens = await exchangeAuthorizationCode({ clientId, clientSecret, code, redirectUri }); Copy
const { code } = parseCallbackUrl(request.url, { expectedState: session.oauthState }); const tokens = await exchangeAuthorizationCode({ clientId, clientSecret, code, redirectUri });
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:
error=access_deniedand no code;stateis missing or does not match the one you issued;Each throws an OAuthError; for a decline,
errorisaccess_denied, which isReauthorizationRequired recognises.