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
Return value
Section titled “Return value”NylasConnect.getAuthUrl()
returns a Promise
that resolves to an object with the following properties.
Property | Type | Description |
---|---|---|
scopes | string[] | An array of granular scopes that Nylas will request from the user. |
state | string | A custom value included in the authorization URL for security purposes. |
url | string | The complete authorization URL that the user is redirected to. |