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:
- Create a Google Cloud project. In the Google Cloud console, project picker, New project. Make sure the new project is the selected one.
- Enable the Gmail API. APIs & Services > Library, search "Gmail API", click Enable.
- 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.
- 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.
- 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 see | Meaning | Fix |
|---|---|---|
| redirect_uri_mismatch | The redirect URL n8n sent is not in your OAuth client's list | Copy the OAuth Redirect URL from the n8n credential and paste it exactly, including http/https and port |
| Access denied / app not verified | App is in Testing and your account is not a test user | Google Auth Platform > Audience > add your email under Test users |
| invalid_client | Client ID or secret does not match | Copy both again from Google, watch for trailing spaces |
| Gmail API has not been used in project … or is disabled | API not enabled in the project | Enable the Gmail API in the same project as the client |
| Authorisation error after about a week | Seven-day expiry in Testing mode | Reconnect; see the section above |
| Insufficient permission / scope | Credential connected without needed access | Reconnect and tick every permission on the Google screen |
Using the Gmail Trigger well
- It polls. Choose a polling interval (every minute to every day). Expect a delay of up to that interval.
- Filter at the source. Use the trigger's Filters (labels, read status, search query) rather than fetching everything and discarding most in the workflow. A query like
is:unread newer_than:1dkeeps the volume small. - Duplicates. If you mark messages as read or label them after processing, the same email will not be picked up twice. If you only read them, add a "processed" label or store message IDs.
- Test mode. Fetch Test Event pulls one recent email so you can see the field names before you build on them.
- Active workflows only. The trigger polls only while the workflow is published; Execute workflow polls once.
Security habits
- Use a separate Google account or test mailbox while building, and only connect your main mailbox when drafts-only behaviour is proven.
- Prefer nodes that create drafts and labels over nodes that send.
- Never paste client secrets into Code nodes, notes or screenshots; keep them in the n8n credential store.
- Back up your
N8N_ENCRYPTION_KEYon self-hosted instances. Without it, saved credentials cannot be decrypted after a rebuild.
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 changed | Check |
|---|---|
| It worked yesterday, fails today | Open the credential and click reconnect. If it works, the token expired; see the seven-day section |
| It never worked | Is the Gmail API enabled in the same Google project as the OAuth client? |
| Only the trigger fails | Is the workflow published? Does the filter query match anything? Try Fetch Test Event |
| Works in test, not in production | Is the credential selected on every Gmail node, and is the workflow saved and published? |
| Works for you, not for a teammate | Test users list in Testing mode, and shared credentials in n8n |
| Mail appears twice | No 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
- n8n docs: Google OAuth2 single service (the managed OAuth list, the seven-day Testing-mode expiry and the redirect URI notes are from this page, read 4 Dec 2026), Gmail Trigger.