Only show these results:

Google Authentication

Google requires that you create an application in the Google console before you can use them with Nylas. See Create a Google Application for more. Depending on the scopes you choose from production, you will need to undergo a Google security review. Nylas can assist you with taking your application to production.

IMAP authentication

Nylas doesn't recommend connecting using IMAP. IMAP has reduced functionality and will eventually be deprecated by Google.

Prerequisites

Google Hosted Authentication Steps

  1. Make sure you have followed the steps to Create a Google Application.
  2. Use Hosted Authentication as normal.

Google Native Authentication Steps

Native Authentication with Google requires you to get a refresh_token from Google. A refresh_token is part of the OAuth 2.0 for access to Google APIs. To implement the refresh_token portion we recommend using one of the Google Client libraries to automate the process.

Google Native Authentication
  1. Make sure you have followed the steps to Create a Google Application.

  2. Redirect the user to your OAuth login page.

  3. Google sends the authentication code to your application.

  4. Request the refresh_token from Google.

  5. Google returns the refresh_token.

  6. Then make a request to /connect/authorize using the google_client_id, google_client_secret and google_refresh_token.

    curl -X POST https://api.nylas.com/connect/authorize -d '{ 
    "client_id": "nylas_client_id",
    "name": "Nyla the Cheetah",
    "email_address": "[email protected]",
    "provider": "gmail",
    "settings": {
    "google_client_id": "{google_api_client_id}",
    "google_client_secret": "{geoogle_api_client_secret}",
    "google_refresh_token": "{google_api_refresh_token}"
    },
    "scopes": "email.read_only,calendar.read_only,contacts.read_only"
    }'
  7. Nylas returns a one-time use authorization code.

  8. Make a request to /connect/token

    curl -X POST "https://api.nylas.com/connect/token" -d '{
    "client_id": "{client-id}",
    "client_secret": "{client-secret}",
    "code": "{nylas_code}"
    }'
  9. Nylas returns an access_token for the account.

Scopes

Before authorizing a user, you want to make sure you have the correct Nylas scopes in your request. If you need to change scopes, the user will have to reauthenticate.

Example Apps

We have created several Google Native Authentication applications so you can see how to implement the process in your app.

What’s Next?