← Back to library

Google Workspace CLI 集成实战:让 OpenClaw 稳定接入 Gmail/Drive/Calendar

问题/场景:需要把 OpenClaw 与 Gmail/Drive/Calendar 打通,但直接调 API 成本高。前置条件:Node.js 18+、Google Cloud 项目、可完成 OAuth。实施步骤:1) 安装 gws;2) gws auth setup/login 完成授权;3) 用 gws drive files list 和 gws schema 验证命令面;4) 再把可用命令接入 OpenClaw 工作流。关键命令:npm install -g @googleworkspace/cli、gws auth login -s drive,gmail,sheets。验证方法:能稳定列出文件并创建测试表格。风险与边界:OAuth testing 模式有 scope 数量上限,需按服务拆分授权。来源归因:googleworkspace/cli README。

GITHUBDiscovered 2026-03-09Author googleworkspace
Prerequisites
  • Node.js 18+ and npm are available on the host.
  • You have a Google account and a Google Cloud project for OAuth credentials.
Steps
  1. Install the CLI: npm install -g @googleworkspace/cli.
  2. Run gws auth setup (or manual OAuth setup) and then gws auth login.
  3. For unverified/testing apps, login with limited scopes: gws auth login -s drive,gmail,sheets.
  4. Validate read/write primitives with gws drive files list and gws sheets spreadsheets create before wiring OpenClaw automations.
Commands
npm install -g @googleworkspace/cli
gws auth setup
gws auth login -s drive,gmail,sheets
gws drive files list --params '{"pageSize": 5}'
gws sheets spreadsheets create --json '{"properties":{"title":"OpenClaw Test"}}'
Verify

CLI can list Drive files and create one test spreadsheet with valid OAuth tokens.

Caveats
  • gws auth setup depends on gcloud; if missing, use manual OAuth setup from docs.
  • Unverified OAuth apps can fail when requesting too many scopes; split by service and re-auth(需验证).
Source attribution

This tip is aggregated from community/public sources and preserved with attribution.

Open original source ↗
Visit original post