Home » n8n» Link Google Sheets to n8n: Beginner Docker OAuth2 Guide

Link Google Sheets to n8n?

This guide shows how to link Google Sheets to n8n for simple automation. You can link Google Sheets to n8n by creating Google OAuth2 credentials, running n8n in Docker with the correct host settings, and adding a Google Sheets credential in the n8n UI.

What You Need

  • An n8n instance running via Docker.
  • A Google account and Google Cloud project.
  • Basic command line access on your machine.
  • Browser to complete OAuth flow.

How to Install n8n with Docker

Start n8n locally so OAuth redirect works. Use this docker command to run n8n on http://localhost:5678.

docker run -it --rm \
  -p 5678:5678 \
  -e N8N_HOST="localhost" \
  -e N8N_PROTOCOL="http" \
  -e N8N_PORT="5678" \
  -e N8N_ENCRYPTION_KEY="your_random_key_here" \
  -v ~/.n8n:/home/node/.n8n \
  n8nio/n8n

Replace your_random_key_here with a secure string. This key encrypts credentials in n8n.

Step 1: Create Google API Credentials

Open the Google Cloud Console and make a project. Enable the Google Sheets API and create OAuth 2.0 Client ID credentials for a Web application.

  1. Enable API: use the Cloud Console or run:
    gcloud services enable sheets.googleapis.com
  2. Create OAuth client and set authorized redirect URI to:
    http://localhost:5678/rest/oauth2-credential/callback
  3. Copy the Client ID and Client Secret to use in n8n.

Step 2: Add Google Sheets Credential in n8n

Open n8n at http://localhost:5678 and log in if needed. Go to Credentials and add a new Google Sheets OAuth2 credential.

  1. Choose OAuth2 for Google Sheets.
  2. Paste the Client ID and Client Secret from Google Cloud.
  3. Click Connect and complete the Google OAuth consent to grant access to Sheets.

Step 3: Use the Google Sheets Node

Create a workflow and add the Google Sheets node. Select the credential you created and choose an operation such as “Append” or “Get Rows.” Test with a small sheet.

{
  "nodes": [
    {
      "parameters": {
        "operation": "append",
        "sheetId": "your_sheet_id",
        "range": "Sheet1!A1"
      },
      "name": "Google Sheets",
      "type": "n8n-nodes-base.googleSheets"
    }
  ]
}

How to Link Google Sheets to n8n

This step ties the pieces: the Google OAuth client handles authentication and n8n stores the token. After connecting, n8n uses the OAuth token to call the Google Sheets API for read and write operations.

Update

If you change host, update the OAuth redirect URI in Google Cloud. To refresh credentials, re-run the OAuth connect flow in the credential settings. Keep n8n updated with:

docker pull n8nio/n8n
docker run ... (use the same environment variables and volume)

Security

  • Keep N8N_ENCRYPTION_KEY secret and long.
  • Restrict OAuth consent and scopes to least privilege (use only Sheets scopes you need).
  • Use HTTPS in production and set proper N8N_HOST and N8N_PROTOCOL to https.
  • Limit Google API client to authorized domains and URIs.
  • Store backups of ~/.n8n securely and use access controls.

Done

You now know how to link Google Sheets to n8n using Docker and OAuth2. Run the example workflow, test a simple append or read, and expand automation from there.


Neil
Written by Neil

Neil is a true n8n geek who lives and breathes workflow automation. He dives deep into nodes, triggers, webhooks, custom logic, and self-hosting setups, sharing everything he learns about n8n on AutomationCompare.com. As part of a broader team of automation specialists, Neil focuses purely on mastering n8n and helping others unlock its full potential.

Keep Reading

Scroll to Top