# Trouble Syncing Gmail with Nylas API – Need Help with OAuth Setup!

**URL:** <https://forums.nylas.com/t/trouble-syncing-gmail-with-nylas-api-need-help-with-oauth-setup/731>\
**Category:** Question and Answers\
**Created:** [June 23, 2025, 5:27am UTC](https://forums.nylas.com/t/trouble-syncing-gmail-with-nylas-api-need-help-with-oauth-setup/731 "2025-06-23T05:27:22Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![marcellosalas](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.nylas.com/marcellosalas/32/254_2.png) [@marcellosalas](https://forums.nylas.com/u/marcellosalas)\
**Post date:** [June 23, 2025, 5:27am UTC](https://forums.nylas.com/t/trouble-syncing-gmail-with-nylas-api-need-help-with-oauth-setup/731/1 "2025-06-23T05:27:22Z")

</div>

Hi everyone,

I am working on integrating Gmail using the Nylas API for an app that automates email follow-ups. I have followed the docs on setting up OAuth but keep hitting a redirect\_uri\_mismatch error when trying to authorize accounts.

Here’s what I have done so far:

- Created a Google Cloud project and set up OAuth 2.0 credentials

- Using the Nylas SDK for Node.js

Still, the OAuth flow fails right after the user grants permission. I suspect I might be missing a step in Google’s consent screen config or redirect handling.

Has anyone faced a similar issue recently: ?? Any tips or sample working configs would be really appreciated. I am trying to ensure a seamless Gmail sync experience. I have also gone through this resource [https://developer.nylas.com/docs/dev-guide/provider-guides/google/](https://developer.nylas.com/docs/dev-guide/provider-guides/google/)[machine-learning-course-in-mumbai](https://www.igmguru.com/machine-learning-ai/machine-learning-training-course-in-mumbai)  
but couldn’t get enough help.

Thanks in advance !!

With Regards,  
Marcelo

---

<div class="post-metadata">

**Author:** ![Saif](https://avatars.discourse-cdn.com/v4/letter/s/9fc348/32.png) [@Saif](https://forums.nylas.com/u/Saif)\
**Post date:** [June 23, 2025, 4:26pm UTC](https://forums.nylas.com/t/trouble-syncing-gmail-with-nylas-api-need-help-with-oauth-setup/731/2 "2025-06-23T16:26:49Z")

</div>

The `redirect_uri_mismatch` error you’re encountering is a common issue when the redirect URI in your Google Cloud project doesn’t match what Nylas expects ([https://support.nylas.com/hc/en-us/articles/4423732212241-Why-is-my-Google-Cloud-Application-having-an-issue-with-Nylas-and-the-redirect-URI](https://support.nylas.com/hc/en-us/articles/4423732212241-Why-is-my-Google-Cloud-Application-having-an-issue-with-Nylas-and-the-redirect-URI)).

## Required Redirect URI Configuration

For your Google Cloud application to work with Nylas, you need to add the correct Authorized Redirect URI in your Google Cloud project. The specific URI depends on your data residency:

- **U.S. Hosted auth** : `https://api.us.nylas.com/v3/connect/callback` ([https://developer.nylas.com/docs/dev-guide/provider-guides/google/create-google-app](https://developer.nylas.com/docs/dev-guide/provider-guides/google/create-google-app))
- **E.U. Hosted auth** : `https://api.eu.nylas.com/v3/connect/callback` ([https://developer.nylas.com/docs/dev-guide/provider-guides/google/create-google-app](https://developer.nylas.com/docs/dev-guide/provider-guides/google/create-google-app))

## Steps to Fix the Issue

1. **Update Google Cloud Console** : Go to your Google Cloud Platform dashboard, select **Credentials** , then update the **Authorized redirect URIs** to include the correct Nylas callback URL above ([https://developer.nylas.com/docs/dev-guide/provider-guides/google/create-google-app](https://developer.nylas.com/docs/dev-guide/provider-guides/google/create-google-app)).
2. **Verify Your Node.js Configuration** : Make sure your Nylas SDK setup matches this pattern ([Using the Node.js SDK | Docs](https://developer.nylas.com/docs/v3/sdks/node)):

javascript

```auto
import Nylas from "nylas";
const nylas = new Nylas({ apiKey: "<NYLAS_API_KEY>", apiUri: "<NYLAS_API_URI>"});

```

([Using the Node.js SDK | Docs](https://developer.nylas.com/docs/v3/sdks/node))

1. **Check Your Auth URL Generation** : Your authentication URL should be generated like this ([Using the Node.js SDK | Docs](https://developer.nylas.com/docs/v3/sdks/node)):

javascript

```auto
app.get("/nylas/auth", (req, res) => { const authUrl = nylas.auth.urlForOAuth2({ clientId: "<NYLAS_CLIENT_ID>", redirectUri: "<YOUR_APP_CALLBACK_URI>", provider: 'google' }); res.redirect(authUrl);});

```

([Using the Node.js SDK | Docs](https://developer.nylas.com/docs/v3/sdks/node))

All the best!
