Adding Gmail OAuth2 to n8n

Before you start, make sure you have:


Step 1: Get your OAuth credentials from Google Cloud

  1. Go to console.cloud.google.com
  2. Select your project
  3. Go to APIs & Services → Credentials
  4. Find your OAuth 2.0 Client ID and click it
  5. Copy your Client ID and Client Secret. You will need these in the next step

Step 2: Create the credential in n8n

  1. Open your n8n instance
  2. Click Settings in the left sidebar
  3. Click Credentials
  4. Click Add credential in the top right
  5. Search for Gmail and select Gmail OAuth2 API
  6. Paste your Client ID and Client Secret from Step 1
  7. Click Sign in with Google
  8. A browser window will open. Sign in with the Google Workspace admin account
  9. Grant the requested permissions
  10. You will be redirected back to n8n. The credential will show as connected

Step 3: Copy your credential ID

You will need this ID when configuring your workflow.

  1. After saving the credential, look at the URL in your browser
  2. Copy the ID at the end of the URL

Example: https://your-n8n.com/credentials/abc123 → your credential ID is abc123

Keep this handy. You will paste it into the configurator form.


Troubleshooting

"Error: redirect_uri_mismatch" Your OAuth redirect URI is not configured correctly in Google Cloud Console. In your OAuth credential settings, add this to the authorised redirect URIs: https://your-n8n.com/rest/oauth2-credential/callback

"Error: access_denied" Make sure the Google account you used to sign in has access to the Gmail API and that the OAuth consent screen is configured correctly in Google Cloud Console.