How to Connect Gmail to n8n (OAuth)
Screenshot-by-screenshot OAuth setup for Gmail trigger and send nodes.
How to Connect Gmail to n8n (OAuth)
You need Gmail connected to n8n to automate email workflows without manual intervention. This guide walks through OAuth 2.0 setup for both Gmail trigger nodes (to monitor incoming mail) and send nodes (to dispatch emails from workflows).
OAuth is the only authentication method that works reliably long-term. Google deprecated "less secure app access" in 2022, and app passwords don't support the full Gmail API scope needed for trigger nodes.
What You Need Before Starting
Required accounts:
- Active n8n instance (self-hosted version 0.220.0+ or n8n Cloud)
- Google Workspace or personal Gmail account with admin access
- Google Cloud Platform account (free tier works fine)
Time required: 15-20 minutes for first-time setup, 5 minutes for subsequent connections.
Cost: Zero. Google Cloud free tier includes 1 billion Gmail API
Step 1: Create Google Cloud Project
- Navigate to console.cloud.google.com
- Click the project dropdown in the top navigation bar (next to "Google Cloud")
- Click "New Project" in the modal that appears
- Enter project name:
n8n-gmail-production(or your preferred naming convention) - Leave organization field blank unless you're using Google Workspace
- Click "Create"
- Wait 10-15 seconds for project creation
- Copy the Project ID from the notification (format:
n8n-gmail-production-123456)
Why this matters: Each Google Cloud project isolates API
Step 2: Enable Gmail API APIClick to read the full definition in our AI & Automation Glossary.
- In the left sidebar, click "APIs& Services" > "Library"APIsClick to read the full definition in our AI & Automation Glossary.
- Type
gmail apiin the search bar - Click the "Gmail API" card (published by Google)APIClick to read the full definition in our AI & Automation Glossary.
- Click the blue "Enable" button
- Wait for the "APIenabled" confirmation (appears in 3-5 seconds)APIClick to read the full definition in our AI & Automation Glossary.
Verification step: Click "APIs
Step 3: Configure OAuth Consent Screen
This screen is what users see when granting n8n access to their Gmail account.
- Go to "APIs& Services" > "OAuth consent screen"APIsClick to read the full definition in our AI & Automation Glossary.
- Select "External" user type (even for Google Workspace accounts)
- Click "Create"
App information section:
- App name:
n8n Email Automation - User support email: Select your email from dropdown
- App logo: Skip (optional)
- Application home page: Enter your n8n instance URL (e.g.,
https://n8n.yourcompany.com) - Application privacy policy: Skip for internal use
- Application terms of service: Skip for internal use
- Authorized domains: Add your n8n domain without protocol (e.g.,
yourcompany.com)
Developer contact information:
- Enter your work email address
- Click "Save and Continue"
Scopes section:
- Click "Add or Remove Scopes"
- Filter for "Gmail API" in the dropdownAPIClick to read the full definition in our AI & Automation Glossary.
- Select these three scopes:
https://mail.google.com/(Full Gmail access)https://www.googleapis.com/auth/gmail.modify(Read and modify but not delete)https://www.googleapis.com/auth/gmail.readonly(Read-only access)
- Click "Update" then "Save and Continue"
Test users section (critical for External apps):
- Click "Add Users"
- Enter the Gmail address that will authenticate with n8n
- Add up to 100 test users (limit for unverified apps)
- Click "Save and Continue"
Summary screen:
- Review all settings
- Click "Back to Dashboard"
Publishing note: Leave the app in "Testing" mode unless you need organization-wide access. Testing mode works indefinitely for up to 100 users.
Step 4: Create OAuth Credentials
- Go to "APIs& Services" > "Credentials"APIsClick to read the full definition in our AI & Automation Glossary.
- Click "Create Credentials" > "OAuth client ID"
- Application type: Select "Web application"
- Name:
n8n-gmail-oauth-client
Authorized JavaScript origins:
- Click "Add URI"
- Enter your n8n instance URL:
https://n8n.yourcompany.com - Do NOT include trailing slash
Authorized redirect URIs:
- Click "Add URI"
- Enter:
https://n8n.yourcompany.com/rest/oauth2-credential/callback - Replace
n8n.yourcompany.comwith your actual n8n domain - The
/rest/oauth2-credential/callbackpath is mandatory and case-sensitive
- Click "Create"
- Copy the Client ID (format:
123456789-abc123.apps.googleusercontent.com) - Copy the Client Secret (format:
GOCSPX-abc123xyz789) - Click "OK" to close the modal
Save these credentials immediately. Store them in your password manager or secure documentation system.
Step 5: Configure Gmail Credentials in n8n
- Open your n8n instance
- Click "Credentials" in the left sidebar
- Click "Add Credential" (top right)
- Search for "Gmail OAuth2 API"APIClick to read the full definition in our AI & Automation Glossary.
- Click the "Gmail OAuth2 API" optionAPIClick to read the full definition in our AI & Automation Glossary.
Credential configuration:
- Credential Name:
Gmail Production OAuth - Client ID: Paste the value from Step 4
- Client Secret: Paste the value from Step 4
- Leave all other fields at default values
- Click "Save"
- Click the "Connect my account" button
- New browser tab opens with Google sign-in
- Select the Gmail account you added as a test user in Step 3
- Click "Continue" on the permission request screen
- Review the scopes (should match what you configured)
- Click "Continue" to grant access
- Browser redirects back to n8n with success message
Troubleshooting authentication failures:
- "Access blocked: This app's request is invalid" = Check redirect URI matches exactly
- "Error 403: access_denied" = Gmail account not added as test user in Step 3
- "Redirect URI mismatch" = Verify n8n instance URL matches authorized origins
Step 6: Add Gmail Trigger Node
Gmail trigger nodes monitor your inbox and execute workflows when new emails arrive.
- Create new workflow or open existing workflow
- Click the "+" button on canvas
- Search for "Gmail Trigger"
- Click "Gmail Trigger" node
Node configuration:
- Credential to connect with: Select "Gmail Production OAuth" from dropdown
- Event: Select "Message Received"
- Filters section:
- Label Names: Leave empty to monitor all mail, or select "INBOX"
- Sender: Leave empty or enter specific email address to filter
- Subject: Leave empty or enter text to match in subject line
Polling interval:
- Default: Every 60 seconds
- Recommended for production: Every 120-300 seconds to avoid rate limits
- Gmail APIfree tier: 250 quota units per user per secondAPIClick to read the full definition in our AI & Automation Glossary.
- Click "Execute Node" to test
- Send a test email to the connected Gmail account
- Wait for polling interval to elapse
- Node should output the email data in JSON format
Common trigger issues:
- No emails appearing = Check label filter matches where test email landed
- "Insufficient permissions" error = Re-authenticate credential with all required scopes
- Rate limit errors = Increase polling interval above 120 seconds
Step 7: Add Gmail Send Node
Gmail send nodes dispatch emails from your workflows.
- Click "+" button after your trigger or any other node
- Search for "Gmail"
- Select "Gmail" (not Gmail Trigger)
Node configuration:
- Credential to connect with: Select "Gmail Production OAuth"
- Resource: "Message"
- Operation: "Send"
Message fields:
- To: Enter recipient email or use expression
{{ $json.from }}to reply to sender - Subject: Enter static text or use expression
Re: {{ $json.subject }} - Message Type: Select "Text" or "HTML"
- Message: Enter email body content
Using expressions for dynamic content:
Hello `{{ $json.payload.headers.find(h => h.name === 'From').value }}`,
Thank you for your email regarding `{{ $json.subject }}`.
This is an automated response from our n8n workflow.
Attachments (optional):
- Click "Add Field" > "Attachments"
- Use binary data from previous nodes
- Reference with expression:
{{ $binary.data }}
- Click "Execute Node" to send test email
- Check recipient inbox for delivery
- Verify sender shows as your authenticated Gmail account
Step 8: Test Complete Workflow
- Click "Execute Workflow" button (top right)
- Workflow enters listening mode (for trigger nodes)
- Send test email to monitored Gmail account
- Wait for polling interval
- Trigger node activates and passes data to send node
- Send node dispatches reply email
- Check execution log for success confirmation
Production deployment:
- Click the toggle switch at top of workflow to "Active"
- Workflow now runs automatically on schedule
- Monitor executions in "Executions" tab
Scope Reference for Advanced Use Cases
Different Gmail operations require different OAuth scopes:
Read-only monitoring:
https://www.googleapis.com/auth/gmail.readonly- Use for: Trigger nodes that only read email metadata
Modify but not delete:
https://www.googleapis.com/auth/gmail.modify- Use for: Marking emails as read, applying labels, moving to folders
Full access (recommended for automation):
https://mail.google.com/- Use for: Send nodes, delete operations, full mailbox management
To change scopes after initial setup:
- Return to Google Cloud Console > OAuth consent screen
- Edit scopes section
- Update scope list
- In n8n, delete existing credential
- Create new credential and re-authenticate
Rate Limits and Quota Management
Gmail API
- 250 quota units for read operations
- 100 quota units for send operations
- 25 quota units for modify operations
Each operation costs:
- Trigger node poll: 5 units
- Send email: 100 units
- Read email body: 5 units
Staying under limits:
- Set trigger polling to 120+ seconds
- Batch operations when possible
- Monitor quota usage in Google Cloud Console > APIs& Services > DashboardAPIsClick to read the full definition in our AI & Automation Glossary.
If you hit rate limits:
- Increase polling intervals
- Implement exponential backoff in error handling
- Request quota increase (requires app verification for >100 users)
Security Best Practices
Credential rotation:
- Rotate OAuth client secrets every 90 days
- Update in both Google Cloud Console and n8n credentials
Access control:
- Limit test users to only those who need workflow access
- Use separate Google Cloud projects for dev/staging/production
- Never commit client secrets to version control
Monitoring:
- Enable Google Cloud audit logs for credential usage
- Set up alerts for unusual APIcall patternsAPIClick to read the full definition in our AI & Automation Glossary.
- Review n8n execution logs weekly for failed authentications
Your Gmail integration is now production-ready. The OAuth connection persists indefinitely unless you revoke access in Google account settings or delete the credential in n8n.

Reviewed by Revenue Institute
This guide is actively maintained and reviewed by the implementation experts at Revenue Institute. As the creators of The AI Workforce Playbook, we test and deploy these exact frameworks for professional services firms scaling without new headcount.
Revenue Institute
Need help turning this guide into reality? Revenue Institute builds and implements the AI workforce for professional services firms.