Briefova

Home › Guides

N8n Gmail trigger and credentials: setup and common errors

Last checked 2026-12-05. Steps follow n8n's published documentation; where we could not run something ourselves we say so.

Short answer: on n8n Cloud, click Sign in with Google in the Gmail credential (managed OAuth2). On self-hosted n8n you create your own OAuth client in Google Cloud Console: enable the Gmail API, configure the consent screen, create a Web application client with n8n's redirect URL, paste the client ID and secret into n8n, then sign in. Most errors come from the redirect URL, test-user list or an app left in Testing mode.

The Gmail node and the Gmail Trigger both need a Google credential. The steps below follow n8n's own documentation for Google OAuth2 single-service credentials, with the errors people hit most often and what they mean. Google Cloud's screens get renamed from time to time, so use the headings below as a map rather than exact button labels.

Option A: n8n Cloud (managed OAuth2)

n8n's docs list Gmail (and Gmail Trigger, Google Sheets, Drive, Calendar and others) as supporting Managed OAuth2 on n8n Cloud. Create a new Gmail OAuth2 API credential, click Sign in with Google, choose the account, accept the permissions and save. You do not need a Google Cloud project. If you prefer your own client, the same credential screen lets you switch to custom OAuth2.

Option B: self-hosted (custom OAuth2)

Managed OAuth2 is not available on self-hosted n8n, so you create the client yourself. Five stages:

  1. Create a Google Cloud project. In the Google Cloud console, project picker, New project. Make sure the new project is the selected one.
  2. Enable the Gmail API. APIs & Services > Library, search "Gmail API", click Enable.
  3. Configure the OAuth consent screen (Google Auth Platform). Give it an app name and support email. Audience: Internal if you use Google Workspace and only your organisation needs it, otherwise External. Under Branding, add your n8n domain as an authorised domain if you have one.
  4. Create the OAuth client. Credentials > Create credentials > OAuth client ID, application type Web application. In the n8n credential screen, copy the OAuth Redirect URL and paste it into Authorized redirect URIs.
  5. Finish in n8n. Paste the client ID and client secret into the credential, click Sign in with Google, approve, save.

If n8n runs on your own computer, you do not need a public domain: n8n's docs note that Google accepts localhost redirect URIs, so a URL such as http://localhost:5678/rest/oauth2-credential/callback works for development. On a server behind a domain, use the exact URL n8n displays, including https and any port.

The seven-day expiry problem

For an app whose audience is External and whose publishing status is Testing, Google expires consent and tokens after seven days. n8n's docs describe this: the symptom is a Gmail node that worked last week and now fails with an authorisation error. You fix it by reconnecting the credential. To stop it recurring you must either publish the app (which, depending on the scopes, can trigger Google's verification process for sensitive scopes) or use an Internal app on Google Workspace. If you automate your own personal mailbox, plan on reconnecting weekly or check the current Google guidance for your situation. This is the single most common reason a "finished" Gmail workflow stops working.

Errors and fixes

Error you seeMeaningFix
redirect_uri_mismatchThe redirect URL n8n sent is not in your OAuth client's listCopy the OAuth Redirect URL from the n8n credential and paste it exactly, including http/https and port
Access denied / app not verifiedApp is in Testing and your account is not a test userGoogle Auth Platform > Audience > add your email under Test users
invalid_clientClient ID or secret does not matchCopy both again from Google, watch for trailing spaces
Gmail API has not been used in project … or is disabledAPI not enabled in the projectEnable the Gmail API in the same project as the client
Authorisation error after about a weekSeven-day expiry in Testing modeReconnect; see the section above
Insufficient permission / scopeCredential connected without needed accessReconnect and tick every permission on the Google screen

Using the Gmail Trigger well

Security habits

Check it works

After saving the credential, add a Gmail node with Label > Get Many and click Execute step. If you see your labels, authentication works. Then try the trigger with Fetch Test Event.

Scopes and what the credential can do

When you click Sign in with Google, Google shows the permissions the credential requests. n8n's Gmail node needs enough access to read, label and create drafts and, if you use those operations, send. If you only intend to read, label and draft, you cannot technically restrict n8n to exclude sending through the standard credential, so the safeguard is in your workflow design: do not include a Send node, and review the workflow before activating it. For maximum caution, build against a separate mailbox first.

Moving a workflow between instances

Exporting a workflow as JSON does not carry credentials with it. After importing on another instance, open each Gmail node, choose or create a credential, and run Execute step once. If the new instance has a different URL, the OAuth redirect URL differs too, so the Google OAuth client must list the new URL (you can have several redirect URIs on one client).

Quick diagnosis table for "it stopped working"

What changedCheck
It worked yesterday, fails todayOpen the credential and click reconnect. If it works, the token expired; see the seven-day section
It never workedIs the Gmail API enabled in the same Google project as the OAuth client?
Only the trigger failsIs the workflow published? Does the filter query match anything? Try Fetch Test Event
Works in test, not in productionIs the credential selected on every Gmail node, and is the workflow saved and published?
Works for you, not for a teammateTest users list in Testing mode, and shared credentials in n8n
Mail appears twiceNo processed marker. Mark read or add a label after handling

If an error mentions "invalid_grant", it generally means the stored refresh token was revoked or expired. Reconnecting creates a new one. Revocation happens when you remove the app's access in your Google account's security page, change your password in some configurations, or hit the Testing-mode limit.

Sources

Client Report & Gmail Triage Kit

The kit below implements the workflow in this guide with test data, a setup guide and a test report.

See the kit · $27

n8n Starter Pack for Freelancers

Not ready to buy? The free starter pack has two working workflows, a scorecard and a credentials checklist so you can test n8n first.

Get the free pack

Related guides

N8n Google Sheets credentials: setup and permission errors

Connect Google Sheets to n8n (managed or custom OAuth, or a service account) and fix 403 caller-does-not-have-permission, 404, quota and tab-name errors.

N8n email triage: classify Gmail and draft replies

Build an n8n Gmail triage workflow with rules first, optional AI JSON classification, labels and reply drafts only. Safety rules and a no-credentials test included.

N8n self-hosted vs cloud free trial: what you get and the limits

What n8n Cloud's free trial and paid plans include, what self-hosted Community Edition requires, and which fits CSV workflows, webhooks and client data. Dated 4 Dec 2026.

Frequently asked questions

Why did my Gmail workflow stop working after a week?

If your Google app is External and in Testing status, consent and tokens expire after seven days. Reconnect the credential, or publish the app or use an Internal Workspace app.

What causes redirect_uri_mismatch?

The OAuth Redirect URL shown in n8n is not listed exactly in your Google OAuth client. Copy it again including protocol and port.

Can I use Gmail with n8n on my own computer?

Yes. Google allows localhost redirect URIs for development, so no public domain is needed to connect the credential.