Skip to content

NylasConnect.getGrantInfo()

NylasConnect.getGrantInfo() retrieves grant information from a stored token, including user details and provider information.

// Get grant info for current session
const grantInfo = await nylasConnect.getGrantInfo();
// Or for a specific grant
const grantInfo = await nylasConnect.getGrantInfo('<NYLAS_GRANT_ID>');

You can pass no parameters to the method if you want to get information about the grant associated with the current session. If you want to get information about a specific grant, pass it as a parameter.

ParameterTypeDescription
grantIdstring?The ID of the grant to access. If not provided, Nylas Connect uses the grant ID associated with the current session.

The getGrantInfo() method returns a Promise<GrantInfo | null> with the following properties.

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.

If no grant information is available, the method returns null.