Automation

How to Configure n8n Google OAuth Credentials for API Access

Learn the step-by-step process to set up Google OAuth credentials for integrating Gmail, Drive, Sheets, and Docs in n8n workflows.

4 min read

Learn how to configure n8n Google OAuth credentials to integrate Google services like Gmail, Drive, Sheets, and Docs into automated workflows. Follow this guide to set up a seamless connection between n8n and your Google account using OAuth.


Prerequisites for Configuring n8n Google OAuth Credentials

Before starting the configuration process, ensure the following requirements are met:

prerequisites

  • You have a valid Google Cloud account.
  • Administrator access to the Google Cloud console.
  • An existing n8n setup and workspace.
  • Basic understanding of OAuth concepts and API integration.

Step-by-Step Configuration Guide

Follow these steps to configure n8n Google OAuth credentials and enable API access:

steps

  1. Create a Google Cloud Project:

    • Log in to the Google Cloud console.
    • Navigate to the project selector and select Create New Project.
    • Enter a name for the project (e.g., n8n-demo) and confirm by clicking Create Project.
  2. Set Up the OAuth Consent Screen:

    • Go to APIs & Services > OAuth Consent Screen.
    • Select “Internal” for private use or “External” if you intend to publish the app.
    • Add app details including the app name and support email.
    • Click Save and Continue.
  3. Add Scopes and Test Users:

    • Define scopes to specify the permissions your app needs (e.g., Gmail read/write or Drive access).
    • Add test users who will interact with the app during the testing phase.
  4. Generate OAuth Credentials:

    • Go to APIs & Services > Credentials and select Create Credentials > OAuth Client ID.
    • Choose Web Application and provide a name.
    • Add the n8n OAuth redirect URI: https://localhost:5678/rest/oauth2-credential/callback.
    • Click Create to generate a Client ID and Client Secret.
  5. Configure n8n:

    • Log in to your n8n workspace and navigate to the credential settings.
    • Enter the Client ID and Client Secret obtained from the Google Cloud console.
    • Save the configuration.
  6. Enable Required APIs:

    • In the Google Cloud console, navigate to APIs & Services > Enabled APIs & Services.
    • Search for and enable APIs such as Google Drive API, Gmail API, Google Sheets API, or Docs API based on your needs.
  7. Test Connections:

    • Log in to n8n and use the Google services in your workflows.
    • Verify operations like fetching a Drive folder, sending an email via Gmail, or accessing data from Sheets.

Common Mistakes and How to Avoid Them

Setting up Google OAuth credentials for n8n can be prone to a few common errors. Here's how to avoid them:


Verifying Successful Integration

After configuring credentials and enabling APIs, follow these steps to confirm integration:

steps

  1. Test API Calls:

    • In n8n, create a workflow that fetches data from a connected service (e.g., list files from Google Drive).
  2. Check Authentication Status:

    • Verify that the connected account shows a green "Success" status in the credentials configuration.
  3. Review API Activity:

    • Open Google Cloud console and check API & Services Usage to confirm interactions with enabled APIs.

FAQ

FAQ

How do I resolve "Redirect URI mismatch" errors?

Ensure that the redirect URI defined in your OAuth Client ID settings matches the exact URI provided by n8n, such as https://localhost:5678/rest/oauth2-credential/callback.

Can I skip test users and directly publish the app?

Yes, if you're publishing the app externally, you can skip adding test users by completing the publication process on the OAuth consent screen.

What APIs should I enable for Google Sheets integration?

Enable the Google Sheets API in your Google Cloud project. Look for additional APIs based on related services, like Charts or Forms API, if required.

Is my Client Secret sensitive information?

Yes, treat your Client Secret as sensitive data. Do not share it publicly and store it securely to avoid unauthorized access.



Official reference: n8n documentation.