To use Gmail in n8n — for example in the Gmail auto-reply workflow — n8n needs permission to read and send your email. On self-hosted n8n you give that permission with a Google OAuth credential: a Client ID and Client Secret you create once in Google Cloud Console. It’s free and takes about ten minutes.
In short
- Create a project in Google Cloud Console and enable the Gmail API.
- Set up the OAuth consent screen (External) and add your Gmail as a test user.
- Create an OAuth client ID (Web application) with n8n’s redirect URL.
- Paste the Client ID and Secret into n8n and click Sign in with Google.

Before you start: copy n8n’s redirect URL
In n8n open Overview → Credentials → Create credential, search Gmail OAuth2 API and keep the window open. Copy the OAuth Redirect URL shown there — on a local install it is:
http://localhost:5678/rest/oauth2-credential/callback
On a server with a domain it looks like https://n8n.yourdomain.com/rest/oauth2-credential/callback.
Step 1: Create a Google Cloud project
- Go to console.cloud.google.com and sign in.
- Click the project dropdown at the top → New project, give it a name (e.g. “n8n”) → Create.
- Make sure the new project is selected in the top bar.
Step 2: Enable the Gmail API
APIs & Services → Library, search Gmail API and click Enable. (Using Google Sheets or Drive later? Enable those APIs the same way.)
Step 3: Configure the OAuth consent screen
- APIs & Services → OAuth consent screen → Get started.
- Enter an App name and your support email → Next.
- Audience: External (any Google account) → Next. Add your contact email, accept the policy and Create.
- Open Audience → Test users → Add users and add the Gmail address you’ll connect. In testing mode only test users can sign in.
- Running n8n on your own domain? In Branding → Authorized domains add that domain.
Step 4: Create the OAuth client ID
- APIs & Services → Credentials → Create credentials → OAuth client ID.
- Application type: Web application. Give it a recognisable name.
- Under Authorized redirect URIs click Add URI and paste n8n’s OAuth Redirect URL exactly.
- Click Create and copy the Client ID and Client Secret from the popup.
Step 5: Finish the credential in n8n
- Paste the Client ID and Client Secret into the n8n credential.
- Click Sign in with Google and choose your Gmail account.
- Google may warn “Google hasn’t verified this app” — that’s expected for your own testing app. Click Continue and allow access.
- When n8n shows the account as connected, click Save.

Common errors
- redirect_uri_mismatch — the URL in Google doesn’t match n8n’s. Copy it again exactly, including
http/httpsand the port. - Access denied / app not verified — add your Gmail as a test user (step 3).
- invalid_client — the Client ID or Secret is wrong; copy both again with no extra spaces.
- Disconnected after 7 days — in testing mode Google expires the sign-in after a week. Click Reconnect in the credential, or publish the app in the consent screen.
Frequently asked questions
Is the Google OAuth credential free?
Yes. Creating a Google Cloud project, enabling the Gmail API and creating an OAuth client ID costs nothing for normal Gmail use.
Do I need a domain or HTTPS for this?
No for a local install — Google accepts http://localhost redirect URLs. On a server, use your n8n domain with HTTPS and add it to Authorized domains.
Why does Google say “Google hasn’t verified this app”?
Because it’s your own app in testing mode. As long as you are a listed test user, click Continue — it’s safe for your own account.
Can I reuse this credential for Google Sheets or Drive?
You can use the same Client ID and Secret, but enable each API (Sheets, Drive) in the project and create a separate n8n credential for that service.
Why did my Gmail credential stop working after a week?
Apps in testing mode with External users get tokens that expire after 7 days. Reconnect the credential, or publish the app to stop the weekly expiry.
What’s next?
Your Gmail credential is ready. Next, get a free Gemini API key for the AI part, then build the Gmail auto-reply workflow.
