Only show these results:

Google Authentication

Google requires that you create an application in the Google console before you can integrate them with Nylas. Check out our article on creating a Google application for more information. Depending on the scopes you choose from production, you'll need to undergo a Google security review. Nylas can assist you with taking your application to production.

IMAP Authentication

Nylas recommends avoiding using IMAP. IMAP has reduced functionality and will eventually be deprecated by Google.

Prerequisites

Google Hosted Authentication Steps

  1. Make sure you've followed the steps to create a Google application.
  2. Use Hosted Authentication as you normally would.

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 protocol and gives you 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

To implement Native Authentication, follow the steps below:

  1. Make sure you've 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. 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": "nyla@nylas.com",
    "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'll want to make sure you have the correct Nylas scopes in your request. If you need to change scopes, the user will have to re-authenticate.

Example Apps

We've created several Google Native Authentication example applications to show you how to implement the process in your app.

What’s Next?