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:
┌─────────────┐│ Gmail │ ─── OAuth Flow 1 ───▶ Credentials A└─────────────┘
┌─────────────┐│ Drive │ ─── OAuth Flow 2 ───▶ Credentials B└─────────────┘
┌─────────────┐│ Calendar │ ─── OAuth Flow 3 ───▶ Credentials C└─────────────┘
... and 40+ more flowsAfter 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 ││ ││ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ ││ │ 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:
npm i -g @googleworkspace/cliI got this output:
added 127 packages in 4.2s
27 packages are looking for funding run `npm fund` for detailsThen I verified the installation:
google-workspace --version0.3.0Step 2: Add as Skill to OpenClaw
Next, I added the CLI as a skill to OpenClaw:
npx skills add github:googleworkspace/cliI expected this to work immediately. It didn’t.
Error: Skills directory not foundPlease create ~/.claude/skills or specify a pathI had to create the skills directory first:
mkdir -p ~/.claude/skillsnpx skills add github:googleworkspace/cliNow it worked:
Cloning github:googleworkspace/cli...Installing dependencies...Skill added: google-workspaceStep 3: Authenticate Once
The moment of truth. I ran the authentication command:
google-workspace auth loginA 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:
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 servicesAfter approval, the CLI stored my credentials securely:
Authentication successful!Credentials stored in ~/.config/google-workspace-cli/credentials.json
Available services: - gmail - drive - calendar - docs - sheets - slides - meet - chat - ... 35+ moreStep 4: Test the Connection
I tested the connection with a simple Gmail query:
google-workspace gmail list-messages --max-results 5It worked:
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:
google-workspace drive list-files --max-results 5Files (5): 1. Q1 Budget Report.xlsx 2. Project Roadmap.docx 3. Team Photos 4. Meeting Notes - March.gdoc 5. API Documentation.pdfNo 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:
{ "mcpServers": { "google-workspace": { "command": "google-workspace", "args": ["mcp", "start"] } }}Now when I ask OpenClaw to do something with Google Workspace, it works:
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:
┌────────────────────────────────────────────────────────────────┐│ 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:
# Check current scopesgoogle-workspace auth scopes
# Request additional scopesgoogle-workspace auth add-scopes gmail.send calendar.eventsThis triggered a new OAuth flow, but only for the new scopes:
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:
cd my-projectnpm install @googleworkspace/cliThis installed it locally, but the skill system expects it globally:
npm i -g @googleworkspace/cliMistake 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:
- Write shell scripts to call the CLI
- Parse the output manually
- 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:
-
Build everything manually: Set up OAuth for each service, handle token management, learn each API’s quirks.
-
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:
- Install globally:
npm i -g @googleworkspace/cli - Add as skill:
npx skills add github:googleworkspace/cli - Authenticate once for all services
- Configure MCP in OpenClaw settings
- 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:
- 👨💻 Google Workspace CLI GitHub Repository
- 👨💻 Model Context Protocol Specification
- 👨💻 OpenClaw Documentation
Oh, and if you found these resources useful, don’t forget to support me by starring the repo on GitHub!
Comments