Skip to content
Skip to main content

Authenticating with Nylas

Last updated:

Nylas creates grants, authenticated connections that give your application access to a user’s email, calendar, and contacts data. Most grants come from an OAuth 2.0 flow. IMAP, iCloud, and Exchange on-premises (EWS) grants use the user’s credentials instead, and bring-your-own authentication creates grants from tokens or credentials you already have. Authentication is part of Nylas Connect, and every API call that reads or writes user data requires a grant_id.

Separate user authentication from API authorization

Section titled “Separate user authentication from API authorization”

OAuth and grants control how users connect their provider accounts to Nylas. The API key on a request controls which Nylas resources the caller can access.

Use Nylas IAM to issue least-privilege API keys for services, workers, and AI agents. An IAM principal combines one resource binding with roles and direct permissions, while the grant continues to represent the connected provider account and its OAuth scopes.

How each authentication method creates a grant

Every method ends with a grant ID that your app uses in API requests. With bring your own auth, your app owns the provider OAuth flow and hands Nylas the tokens. If a grant already exists for the same email and connector, Nylas re-authenticates it and keeps its ID.
Diagram as text
  • One of these paths:
    • Hosted auth
      • Your app: Send the user to Nylas: Redirect to /v3/connect/auth with your client_id and redirect_uri. Add a code_challenge for PKCE.
        • Optional parameter provider: skip the provider picker. Without it, Nylas shows a hosted page where the user chooses.
        • Optional parameter login_hint: prefill the user's email address.
        • Optional parameter scope: request specific scopes. Without it, Nylas uses the connector's default scopes.
        • Optional parameter state: a value Nylas returns to you after sign-in.
      • User: Signs in: On the provider's consent screen (Google, Microsoft, Yahoo, Zoom), or in a Nylas-hosted form for IMAP, iCloud, and EWS passwords.
      • Your app: Exchange the code: POST /v3/connect/token with the one-time code, plus the code_verifier for PKCE. (code sent to your redirect_uri)
    • Bring your own auth
      • Your app: Run your own OAuth flow: Send the user to the provider's consent screen with your own OAuth app.
      • Provider: Returns tokens: Your app receives the user's refresh token.
      • Your backend: Send the tokens to Nylas: POST /v3/connect/custom with the refresh token, or IMAP credentials, and your API key.
    • Agent Account
      • Your backend: Create the account: POST /v3/connect/custom with provider set to "nylas". Nylas creates the mailbox, with no user sign-in.
  • Nylas: Existing grant?: Nylas looks for a grant with the same email and connector.
  • Ends in one of:
    • No match → New grant ID: The grant starts as valid. Nylas sends grant.created.
    • Match found → Same grant ID: Nylas re-authenticates the grant and sends grant.updated with reauthentication_flag: true.
MethodBest forToken managementRequires redirect UI?Supported providers
Hosted OAuth (API key)Most server-side integrationsNylas managesYesGoogle, Microsoft, Yahoo (OAuth), plus iCloud, IMAP, and EWS (Nylas-hosted credentials form)
@nylas/connect libraryBrowser and single-page appsLibrary managesOptionalGoogle, Microsoft, IMAP, iCloud
Hosted OAuth (access token + PKCE)SPAs and mobile appsYou manage refreshYesGoogle, Microsoft
Bring your own authenticationTeams with an existing OAuth flowYou manage entirelyNoGoogle, Microsoft, Yahoo, Zoom, IMAP, iCloud, EWS, Agent Accounts
IMAPLegacy or self-hosted email serversApp passwordsYes, except with bring your own authenticationAny IMAP server
Service accountServer-to-server, no user interactionNylas managesNoGoogle Workspace

Before setting up authentication, you need:

  1. Log in to the Nylas Dashboard and create a Nylas application.
  2. Get your application’s API key.
  3. Create auth apps for the providers you plan to integrate with.
  4. Create connectors for your provider auth apps. Nylas supports Google, Microsoft, IMAP, Exchange on-premises, iCloud, Yahoo, and Zoom Meetings.
  5. Add your project’s callback URIs to your Nylas application.
  6. Authenticate your users and create grants for them.

If you plan to connect Google or Microsoft accounts, you need a provider auth app. You can use it with internal accounts right away for development and testing. The provider review only matters before you go live.

Request only the most restrictive scopes you need. If you request any of Google’s restricted scopes, Google requires a full security assessment. This can significantly extend your verification timeline.

See the Google verification and security assessment guide for details.

Connectors store your provider app credentials so you don’t need to include them in every API call. You can’t create grants without at least one connector.

Create connectors from the Nylas Dashboard under Connectors, or with the Create Connector API endpoint.

Each connector supports multiple credentials, letting you use different provider auth apps with a single connector. You can also set default scopes per connector and override them when creating individual grants.

For bulk setup and multi-app configurations, see Bulk authentication grants and Using multiple provider applications.

Add callback URIs to your Nylas application

Section titled “Add callback URIs to your Nylas application”

Callback URIs are where Nylas redirects users after they complete authentication.

  1. Log in to the Nylas Dashboard.
  2. On your application’s page, click Hosted Authentication > Callback URIs in the left navigation.
  3. Click Add a callback URI.
  4. Select the platform and enter a URL.
  5. Click Add callback URI.

Whitelabel Hosted Authentication: replace the Nylas logo on the login page, and register a custom hostname so your own domain appears in the address bar during the OAuth flow.

Grants can expire when users change passwords, revoke access, or when provider tokens are invalidated. Expired grants are recoverable through re-authentication, which preserves the grant ID, object IDs, and sync state. See Handling expired grants for best practices on detection and recovery.