Skip to content
Skip to main content
GET
/v3/connect/auth

Hosted OAuth - Authorization Request

The initial OAuth 2.0 authorization request. Use this endpoint with the required query parameters to start the OAuth 2.0 process. The query parameters pass details to the Nylas API about how the user should authenticate, and where they should go after authenticating. This endpoint supports the authorization code flow and optional PKCE settings for client-side only applications. For more information, see the Hosted OAuth with access token and Hosted OAuth with access token and PKCE documentation.

ACCESS TOKENNYLAS API KEY

Parameters

Query parameters

client_id*string

Your Nylas application's client ID (or application ID).

providerstring

The connector provider type that you set up with Nylas for this application. If the provider isn't set, the user is directed to the Nylas Hosted login page and prompted to select their provider. Multiple providers can be set as a comma-separated list.

googlemicrosoftimapicloudyahooewszoom
redirect_uri*string

Your project's callback URI (used as the OAuth redirect_uri). This is where the OAuth provider sends a user after they authenticate using Hosted OAuth. This must be URL-encoded.

Example: "redirect_uri=https%3A%2F%2Fapp.example.com&"
response_type*string

Specifies the type of response Nylas returns for the authorization flow. Should be set to code for the OAuth 2.0 flow, and adminconsent for the Microsoft admin consent service flow.

codeadminconsent
scopestring

A space-delimited list of scopes that identify the resources that your application may access on the user's behalf. If no scopes are set, Nylas uses the default connector scopes.

promptstring

(Optional) The prompt for the Hosted login page. This parameter can accept multiple values separated by a comma, without spaces in between. The order of the prompts affects the UI of the Hosted login page.

If provider is not set, the user is redirected to the provider page directly, and the prompt is ignored.

select_providerdetectselect_provider,detectdetect,select_provider
Default: "select_provider"
statestring

(Optional) The state of the grant, returned after authentication. The maximum length is 256 characters.

login_hintstring

Prefill the login name (usually the email address) during the authentication flow. If a grant already exists for the provided email address, Nylas automatically re-authenticates the grant.

access_typestring

Specifies whether Nylas should return a refresh token along with the exchange token. This isn't suitable for client-side or JavaScript applications.

offlineonline
code_challengestring

Specifies a Base64-encoded code_verifier without padding. The verifier is used as a server-side challenge during the authorization code exchange.

code_challenge_methodstring

Specifies the method used to encode the code_verifier. The verifier is used as a server-side challenge during the authorization code exchange.

plainS256
Default: "plain"
credential_idstring

The ID of an existing Nylas connector's credential record. If you set the response_type value to code then you can use the credential to override an OAuth connector's default settings and create a grant. You need to create a credential record before you can make a credential override request. If not provided, connector's default "active_credential_id" is used. If you set the response_type value to adminconsent, with provider Microsoft, then this will be the OAuth of Microsoft's Service Account Admin Consent flow. You need to set up the Microsoft connector with an Admin Consent credential before you can make this request.

optionsstring

(Google only) Set to exclude_google_granted_scopes to exclude Google-granted scopes from the authorization request.

Responses

GEThttps://api.us.nylas.com/v3/connect/auth?redirect_uri=redirect_uri%3Dhttps%253A%252F%252Fapp.example.com%26&prompt=select_provider&code_challenge_method=plain

Find your API key in the Nylas Dashboard under API Keys in your application settings.

client_idrequiredstring

Your Nylas application's client ID (or application ID).

redirect_urirequiredstring

Your project's callback URI (used as the OAuth redirect_uri). This is where the OAuth provider sends a user after they authenticate using Hosted OAuth. This must be URL-encoded.

response_typerequiredstring

Specifies the type of response Nylas returns for the authorization flow. Should be set to code for the OAuth 2.0 flow, and adminconsent for the Microsoft admin consent service flow.