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
- Hosted Authentication
- Native Authentication
- Google recently made some changes to how end users approve scopes, review our guide to make sure your users have a seamless experience. Nylas’ Google Auth Guide
Google Hosted Authentication Steps
- Make sure you have followed the steps to Create a Google Application.
- 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.

-
Make sure you have followed the steps to Create a Google Application.
-
Redirect the user to your OAuth login page.
-
Google sends the authentication code to your application.
-
Request the refresh_token from Google.
-
Google returns the
refresh_token
. -
Then make a request to /connect/authorize using the
google_client_id
,google_client_secret
andgoogle_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"
}' -
Nylas returns a one-time use authorization code.
-
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}"
}' -
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.