Skip to content

How Do I Connect OpenClaw to Google Workspace? A Complete Setup Guide

Problem

I wanted to connect OpenClaw to my Google Workspace account. I needed to access Gmail, Google Drive, Calendar, Docs, and Sheets from my AI agent workflows.

My first attempt was a disaster. I started by setting up OAuth for Gmail:

OAuth Configuration Hell
┌─────────────┐
│ Gmail │ ─── OAuth Flow 1 ───▶ Credentials A
└─────────────┘
┌─────────────┐
│ Drive │ ─── OAuth Flow 2 ───▶ Credentials B
└─────────────┘
┌─────────────┐
│ Calendar │ ─── OAuth Flow 3 ───▶ Credentials C
└─────────────┘
... and 40+ more flows

After spending an entire afternoon on OAuth configurations, I had:

  • 5 different credential files
  • 3 expired tokens that needed refreshing
  • 2 scope conflicts between services
  • Zero working integrations

Each service required its own OAuth flow. Each had different API patterns. I was drowning in configuration hell.

What I Discovered

Then I found out Google released an official CLI tool: @googleworkspace/cli. This changed everything.

The key insight: One CLI, one authentication, 40+ services.

Google Workspace CLI Architecture
┌──────────────────────────────────────────────────────┐
│ Google Workspace CLI │
│ │
│ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ │
│ │ Gmail │ │ Drive │ │Calendar │ │ Docs │ │
│ └─────────┘ └─────────┘ └─────────┘ └─────────┘ │
│ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ │
│ │ Sheets │ │ Slides │ │ Meet │ │ Chat │ │
│ └─────────┘ └─────────┘ └─────────┘ └─────────┘ │
│ ... 40+ more ... │
└──────────────────────────────────────────────────────┘
│ Single OAuth Flow
┌───────────────┐
│ OpenClaw │
└───────────────┘

Step 1: Install the CLI Globally

First, I installed the Google Workspace CLI:

Terminal
npm i -g @googleworkspace/cli

I got this output:

Installation Output
added 127 packages in 4.2s
27 packages are looking for funding
run `npm fund` for details

Then I verified the installation:

Terminal
google-workspace --version
Version Output
0.3.0

Step 2: Add as Skill to OpenClaw

Next, I added the CLI as a skill to OpenClaw:

Terminal
npx skills add github:googleworkspace/cli

I expected this to work immediately. It didn’t.

Error Output
Error: Skills directory not found
Please create ~/.claude/skills or specify a path

I had to create the skills directory first:

Terminal
mkdir -p ~/.claude/skills
npx skills add github:googleworkspace/cli

Now it worked:

Success Output
Cloning github:googleworkspace/cli...
Installing dependencies...
Skill added: google-workspace

Step 3: Authenticate Once

The moment of truth. I ran the authentication command:

Terminal
google-workspace auth login

A browser window opened with the Google OAuth consent screen. I selected my Google Workspace account and granted permissions.

Here’s what surprised me: I only had to do this once.

The OAuth screen showed all the services I was granting access to:

OAuth Consent Screen
Google Workspace CLI wants to access:
- Gmail (read, compose, send)
- Google Drive (read, write, share)
- Google Calendar (read, write, events)
- Google Docs (read, edit)
- Google Sheets (read, edit)
- ... and 35+ more services

After approval, the CLI stored my credentials securely:

Auth Output
Authentication successful!
Credentials stored in ~/.config/google-workspace-cli/credentials.json
Available services:
- gmail
- drive
- calendar
- docs
- sheets
- slides
- meet
- chat
- ... 35+ more

Step 4: Test the Connection

I tested the connection with a simple Gmail query:

Terminal
google-workspace gmail list-messages --max-results 5

It worked:

Gmail Output
Messages (5):
1. [INBOX] Project Update - Weekly Report
2. [INBOX] Meeting Tomorrow at 3pm
3. [IMPORTANT] Action Required: Review Document
4. [INBOX] Re: API Integration Questions
5. [SPAM] You've won a prize!

Then I tried Drive:

Terminal
google-workspace drive list-files --max-results 5
Drive Output
Files (5):
1. Q1 Budget Report.xlsx
2. Project Roadmap.docx
3. Team Photos
4. Meeting Notes - March.gdoc
5. API Documentation.pdf

No separate OAuth. No additional configuration. Just worked.

Step 5: Use with OpenClaw via MCP

The real power comes from MCP (Model Context Protocol) integration. OpenClaw can now interact with all my Google services through natural language.

The CLI includes built-in MCP support. I configured it in my OpenClaw settings:

~/.claude/settings.json
{
"mcpServers": {
"google-workspace": {
"command": "google-workspace",
"args": ["mcp", "start"]
}
}
}

Now when I ask OpenClaw to do something with Google Workspace, it works:

OpenClaw Conversation Example
Me: Find all emails from [email protected] in the last week and create
a summary document in Google Docs
OpenClaw: I'll search Gmail for emails from [email protected] in the
last 7 days, then create a summary in Google Docs.
[Uses gmail.search tool]
[Uses docs.create tool]
Done! I found 12 emails and created a summary document:
"Weekly Email Summary from John" in your Google Drive.

The Architecture

Here’s how everything connects:

System Architecture Diagram
┌────────────────────────────────────────────────────────────────┐
│ OpenClaw │
│ │
│ User: "Find emails from [email protected]" │
│ │ │
│ ▼ │
│ ┌─────────────────────────────────────────────────────────┐ │
│ │ MCP Client │ │
│ │ │ │
│ │ Routes requests to: │ │
│ │ - gmail.search │ │
│ │ - drive.list │ │
│ │ - calendar.events │ │
│ │ - docs.create │ │
│ │ - etc. │ │
│ └─────────────────────────────────────────────────────────┘ │
└────────────────────────────────────────────────────────────────┘
│ stdio/SSE
┌────────────────────────────────────────────────────────────────┐
│ Google Workspace CLI (MCP Server) │
│ │
│ ┌─────────────────────────────────────────────────────────┐ │
│ │ Unified OAuth Credentials │ │
│ │ │ │
│ │ Single token for all 40+ services │ │
│ └─────────────────────────────────────────────────────────┘ │
│ │ │
│ ▼ │
│ ┌─────────────────────────────────────────────────────────┐ │
│ │ Google API Client │ │
│ │ │ │
│ │ Handles: │ │
│ │ - Token refresh │ │
│ │ - Rate limiting │ │
│ │ - Error handling │ │
│ │ - Response formatting │ │
│ └─────────────────────────────────────────────────────────┘ │
└────────────────────────────────────────────────────────────────┘
│ HTTPS
┌────────────────────────────────────────────────────────────────┐
│ Google Workspace APIs │
│ │
│ Gmail API │ Drive API │ Calendar API │ Docs API ... │
└────────────────────────────────────────────────────────────────┘

What About Scope Permissions?

One thing I got wrong initially: I thought one OAuth meant all permissions. Not quite.

You still need to grant appropriate scopes for each service. The CLI handles this elegantly:

Terminal
# Check current scopes
google-workspace auth scopes
# Request additional scopes
google-workspace auth add-scopes gmail.send calendar.events

This triggered a new OAuth flow, but only for the new scopes:

Scope Update Output
Opening browser for additional authorization...
New scopes requested:
- https://www.googleapis.com/auth/gmail.send
- https://www.googleapis.com/auth/calendar.events
Authorization complete. Scopes updated.

What I Got Wrong

I made several mistakes during setup. Here are the common pitfalls:

Mistake 1: Expecting enterprise support

I opened a ticket thinking I’d get Google support. Then I read the documentation:

“This is not an officially supported Google product. There is no SLA or support guarantee.”

It’s open-source, community-supported. Issues go to GitHub, not Google Support.

Mistake 2: Installing locally instead of globally

My first attempt:

Terminal (WRONG)
cd my-project
npm install @googleworkspace/cli

This installed it locally, but the skill system expects it globally:

Terminal (CORRECT)
npm i -g @googleworkspace/cli

Mistake 3: Ignoring the MCP integration

I initially used the CLI just as a command-line tool. Then I realized the MCP integration is where the real value is. Without MCP, I’d have to:

  1. Write shell scripts to call the CLI
  2. Parse the output manually
  3. Pass results to OpenClaw somehow

With MCP, OpenClaw can directly use Google Workspace as tools. Much cleaner.

Mistake 4: Assuming all services have equal coverage

Some services are more complete than others. Gmail and Drive have full coverage. Some newer services have limited operations. Check the documentation before relying on a specific API.

Why This Matters

Before this CLI, I had two choices:

  1. Build everything manually: Set up OAuth for each service, handle token management, learn each API’s quirks.

  2. Use third-party integrations: Pay for services like Zapier or Make, with their own limitations and costs.

Now I have a third option: Official CLI with unified authentication and built-in MCP support.

The benefits:

  • Reduced complexity: One auth flow vs. 40+ separate configurations
  • Faster development: Unified API patterns across all services
  • Better AI integration: MCP support enables natural language interactions
  • Open-source transparency: Code is auditable
  • Cost-effective: No additional licensing fees

Summary

In this post, I showed how to connect OpenClaw to Google Workspace using the official CLI. The key steps are:

  1. Install globally: npm i -g @googleworkspace/cli
  2. Add as skill: npx skills add github:googleworkspace/cli
  3. Authenticate once for all services
  4. Configure MCP in OpenClaw settings
  5. Use through natural language

What took me an entire afternoon of frustration with manual OAuth now takes 5 minutes with the CLI. One authentication flow gives me access to 40+ Google Workspace services through OpenClaw.

The CLI is open-source and community-supported, so don’t expect enterprise SLA. But for AI agent integrations, it’s exactly what I needed.

Final Words + More Resources

My intention with this article was to help others share my knowledge and experience. If you want to contact me, you can contact by email: Email me

Here are also the most important links from this article along with some further resources that will help you in this scope:

Oh, and if you found these resources useful, don’t forget to support me by starring the repo on GitHub!

Comments