NylasConnect.getSession()
retrieves the complete session data for a grant, including tokens and user information.
// Get session data for current grantconst session = await nylasConnect.getSession();// Or for a specific grantconst session = await nylasConnect.getSession('<NYLAS_GRANT_ID>');
You can pass no parameters to the method if you want to check the grant associated with the current session. If you want to check a specific grant, pass it as a parameter.
Parameter | Type | Description |
---|---|---|
grantId | string? | The ID of the grant to access. If not provided, Nylas Connect uses the grant ID associated with the current session. |
Return value
Section titled “Return value”The getSession()
method returns a Promise<SessionData | null>
with the following properties.
Property | Type | Description |
---|---|---|
accessToken | string | The access token associated with the 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 user information. |
refreshToken | string? | An optional refresh token used to renew access tokens. |
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. |