REFERENCE / GOOGLE
Gmail / 20 min

Connect Gmail to n8n with OAuth

Enable the Gmail API, create a Google OAuth client, and connect one mailbox to n8n.

Which API do you need?

Enable the Gmail API in Google Cloud. The Gmail Trigger and Gmail action in n8n use this API to watch, read, label, and send messages.

1Enable Gmail API
2Set up consent
3Create client
4Connect n8n

Create the Google project

  1. Create or choose a project in Google Cloud Console.
  2. Open APIs & Services → Library.
  3. Search for Gmail API and enable it.
  4. Open Google Auth Platform and complete the branding and audience sections.
  5. If the app is External and still in Testing, add the Gmail account as a test user.

Google OAuth apps in External testing mode can issue tokens that expire after seven days. Move the app to production when it is ready and complete any verification Google requires.

Create the OAuth client

  1. In n8n, create a Gmail OAuth2 credential and copy its OAuth Redirect URL.
  2. In Google Cloud, create an OAuth client with application type Web application.
  3. Paste the n8n URL into Authorized redirect URIs exactly as shown.
  4. Copy the Client ID and Client Secret into n8n.
  5. Select Sign in with Google, choose the mailbox, approve access, and save.

The protocol, domain, port, path, and trailing slash must match. If they do not, Google returns redirect_uri_mismatch.

What access should you give?

For a workflow that only watches and reads mail, use read-only Gmail access where the credential supports it. If the workflow also marks messages as read, moves them, or adds labels, it needs modify access. Sending mail needs send access.

n8n’s Gmail credential requests the scopes used by its Gmail nodes. Keep the workflow itself read-only unless it has a clear reason to change or send mail.

Test it

Add a Gmail Trigger, choose Message Received, and set a sender or Gmail search filter. Send one test email and confirm the trigger returns its subject, sender, body, and message ID.

Official references: n8n Google OAuth setup, n8n Gmail Trigger, and Gmail API.