DEV Community

Cristian Tala
Cristian Tala

Posted on

Google Service Account in n8n: Complete 2026 Guide

Why You Should Use Google Service Accounts in n8n (And How to Set Them Up)

Need to configure a Google Service Account in n8n for your automations? If you're using OAuth to connect to Google Sheets, Drive, or Gmail, you're probably making a mistake that will cost you time and headaches later.

When I first started automating workflows in n8n, I used OAuth like everyone else. It's easier, faster... until it breaks. Tokens expire, credentials get invalidated when you change your password, and worse: if a team member leaves, all the workflows tied to their account die.

The professional solution: configure Google Service Accounts correctly from the start.

In this tutorial I'll explain what they are, why they matter for technical founders, and how to set them up step by step.

What Is a Service Account and Why Does It Matter?

A Service Account is a special Google account designed for applications and automations — not humans.

Key differences from OAuth:

OAuth (the "easy" method):

  • Tied to a specific user
  • Requires periodic reauthorization
  • Breaks if you change your Google password
  • If the user loses access, all workflows fail

Service Account (the professional method):

  • Independent of human users
  • No reauthorizations (permanent credentials)
  • Works even if you change passwords
  • Ideal for production and teams

For founders and startups: If you're automating critical business processes (CRM, billing, reports), you need stability. Service Accounts give you that.

When to Use Service Accounts in n8n

Use Service Accounts if:

  • You're automating critical business processes
  • You use Google Sheets as a database
  • You need workflows to run without supervision
  • You share workflows across multiple people
  • You want to avoid re-authentication every few months

Real use cases:

  • Automated CRM: Syncing leads between forms and Google Sheets
  • Automatic reports: Daily report generation in Sheets from your database
  • File management: Auto-uploading/moving files in Google Drive
  • Transactional emails: Sending from Gmail without depending on a personal account

Step 1: Create a Project in Google Cloud Console

You need a Google Cloud project. It's free for basic use.

Instructions:

  1. Go to Google Cloud Console
  2. Sign in with your Google account
  3. Click the project dropdown (top left)
  4. Select "New Project"
  5. Give it a descriptive name (e.g., "n8n-automations")
  6. Click Create

Tip: I recommend a dedicated project for n8n to keep things organized.

Step 2: Enable Required APIs

Google requires you to explicitly enable each API you'll use.

Common APIs for n8n:

  • Google Sheets API
  • Google Drive API
  • Gmail API
  • Google Calendar API

How to enable:

  1. In the sidebar, go to "APIs & Services" > "Library"
  2. Search for "Google Sheets API"
  3. Click on the API, then click "Enable"
  4. Repeat for each API you need

Which ones to enable? Depends on your workflows. If you use Google Sheets, enable Sheets + Drive (Drive is needed for file permissions).

Step 3: Create the Service Account

Instructions:

  1. Go to "APIs & Services" > "Credentials"
  2. Click "Create Credentials" > "Service account"
  3. Fill in the fields:
    • Name: Something descriptive (e.g., "n8n-service-account")
    • ID: Auto-generated (leave it)
    • Description: Optional
  4. Click Create and continue
  5. Role: Leave blank for now (we'll handle it via Sheets sharing)
  6. Click Continue then Done

Important: The Service Account has its own email (something like name@project.iam.gserviceaccount.com). You'll need this later.

Step 4: Generate the JSON Key

The JSON file contains the credentials n8n will use to authenticate.

Instructions:

  1. In the service accounts list, click the one you just created
  2. Go to the "Keys" tab
  3. Click "Add Key" > "Create new key"
  4. Select JSON format
  5. Click Create

The file downloads automatically. Store it securely. It's like a password — whoever has that file can act as your Service Account.

File structure:

{
  "type": "service_account",
  "project_id": "your-project",
  "private_key_id": "...",
  "private_key": "-----BEGIN PRIVATE KEY-----\n...",
  "client_email": "name@project.iam.gserviceaccount.com",
  "client_id": "...",
  "auth_uri": "https://accounts.google.com/o/oauth2/auth",
  "token_uri": "https://oauth2.googleapis.com/token"
}
Enter fullscreen mode Exit fullscreen mode

Step 5: Share Google Sheets with the Service Account

Here's the step most people miss.

The Service Account has its own email. For it to access your Google Sheets, you have to explicitly share the document with it.

Instructions:

  1. Open the Google Sheet you want to use in n8n
  2. Click Share (top right)
  3. Paste the Service Account email (the one ending in @....iam.gserviceaccount.com)
  4. Set permissions:
    • Editor: If n8n will write/modify data
    • Viewer: If it will only read
  5. Uncheck "Notify people" (pointless — it's a bot)
  6. Click Share

Repeat this for every Sheet/Drive folder you use in n8n.

Step 6: Configure the Credential in n8n

Instructions:

  1. In n8n, go to Credentials (sidebar)
  2. Click "Add Credential"
  3. Search for "Google Service Account"
  4. Open the downloaded JSON file in a text editor
  5. Fill in the fields in n8n:

Required fields:

  • Service Account Email: Copy the client_email value from the JSON
  • Private Key: Copy the full private_key value (including -----BEGIN PRIVATE KEY----- and -----END PRIVATE KEY-----)

Optional fields (leave as default):

  • Impersonate a User: OFF (only enable if you need to act as a specific Google Workspace user)
  • Set up for use in HTTP Request node: OFF
  1. Give it a descriptive name (e.g., "Google Service Account — Production")
  2. Click Test connection to verify
  3. If it shows "Connection tested successfully ✅", click Save

Pro tip: You can use the same Service Account for multiple nodes (Sheets, Drive, Gmail). No need for one per service.

Step 7: Use It in Your Workflows

Now, in any Google node in n8n, select your Service Account credential instead of OAuth.

Example — Read from Google Sheets:

  1. Add "Google Sheets" node
  2. Operation: Read rows
  3. Credential: Select your Service Account
  4. Sheet ID: Paste from the URL (the long string between /d/ and /edit)
  5. Range: Sheet1!A:Z

That's it. No reauthorizations. No expiring tokens. Works forever.

Common Errors and Solutions

"The caller does not have permission"
→ You forgot to share the Sheet with the Service Account email. Go back to Step 5.

"Service account does not have access to this spreadsheet"
→ Same as above — sharing is the #1 missed step.

"Invalid JWT: No pem found"
→ The private key was pasted incorrectly. Make sure to include the full key with the -----BEGIN/END----- headers.

"API has not been used in project"
→ You forgot to enable the API in Step 2. Go to Cloud Console and enable it.

Why This Matters for Founders

I've helped dozens of founders set up their n8n automations. The ones who used OAuth were back in my inbox 3-6 months later: "My workflows broke, what happened?"

Service Accounts are a 30-minute setup that prevents months of headaches. If you're building anything production-critical with Google services, this is non-negotiable.

The difference between hobby automations and production automations is not the complexity of the workflow — it's the reliability of the infrastructure underneath.


📝 Originally published in Spanish at cristiantala.com

Top comments (0)