Skip to content

NylasConnect.handleRedirectCallback()

NylasConnect.handleRedirectCallback() handles the OAuth redirect callback after completing the inline authentication flow. This method processes the authorization code and exchanges it for tokens.

// Handle callback after OAuth redirect
const result = await nylasConnect.handleRedirectCallback();
// Or with a specific URL
const result = await nylasConnect.handleRedirectCallback(window.location.href);

You can pass no parameters to the method if you want to handle the callback using the current window location. If you want to use a specific URL, pass it as a parameter.

ParameterTypeDescription
urlstringThe URL to process. If not provided, Nylas Connect uses the current window location.

The handleRedirectCallback() method returns a Promise<ConnectResult> with the following properties.

ParameterTypeDescription
accessTokenstringThe access token associated with the user’s grant.
expiresAtnumberWhen the access token will expire, in seconds using the Unix timestamp format.
grantIdstringA unique identifier for the user’s grant.
grantInfoGrantInfo?Optional grant information from the idToken.
idTokenstringAn ID token containing information about the user.
scopestringA space-delimited list of scopes associated with the user’s grant.
PropertyTypeDescription
emailstringThe email address associated with the grant.
emailVerifiedboolean?When true, indicates that the user has verified their email address.
familyNamestring?The user’s surname (last name).
givenNamestring?The user’s given (first) name.
idstringA unique identifier for the user’s grant.
namestring?The user’s display name.
picturestring?A URL that links to the user’s profile picture.
providerstringThe OAuth provider that the user authenticated with.