Skip to content

NylasConnect.getAuthUrl()

The getAuthUrl() method builds an authorization URL for backend-only flows (authentication flows that don’t use PKCE). This method doesn’t store state information or perform a token exchange — it’s intended for server-side exchanges using an API key.

const authData = await nylasConnect.getAuthUrl({
provider: "google",
scopes: ["https://www.googleapis.com/auth/gmail.readonly"]
});
console.log('Authorization URL:', authData.url);

You can pass the following options to customize the authentication flow.

Property
Toggle details

NylasConnect.getAuthUrl() returns a Promise that resolves to an object with the following properties.

PropertyTypeDescription
scopesstring[]An array of granular scopes that Nylas will request from the user.
statestringA custom value included in the authorization URL for security purposes.
urlstringThe complete authorization URL that the user is redirected to.