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 redirectconst result = await nylasConnect.handleRedirectCallback();// Or with a specific URLconst 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.
| Parameter | Type | Description |
|---|---|---|
url | string | The URL to process. If not provided, Nylas Connect uses the current window location. |
Return value
Section titled “Return value”The handleRedirectCallback() method returns a Promise<ConnectResult> with the following properties.
| Parameter | Type | Description |
|---|---|---|
accessToken | string | The access token associated with the user’s grant. |
expiresAt | number | When the access token will expire, in seconds using the Unix timestamp format. |
grantId | string | A unique identifier for the user’s grant. |
grantInfo | GrantInfo? | Optional grant information from the idToken. |
idToken | string | An ID token containing information about the user. |
scope | string | A space-delimited list of scopes associated with the user’s grant. |
GrantInfo
Section titled “GrantInfo”| Property | Type | Description |
|---|---|---|
email | string | The email address associated with the grant. |
emailVerified | boolean? | When true, indicates that the user has verified their email address. |
familyName | string? | The user’s surname (last name). |
givenName | string? | The user’s given (first) name. |
id | string | A unique identifier for the user’s grant. |
name | string? | The user’s display name. |
picture | string? | A URL that links to the user’s profile picture. |
provider | string | The OAuth provider that the user authenticated with. |