gws-install

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Google Workspace CLI — Quick Install

Google Workspace CLI — 快速安装

Install
gws
on an additional machine using OAuth credentials from a previous setup. Produces an authenticated CLI with all agent skills ready to use.
Prerequisite: The user must have
client_secret.json
from a previous
gws-setup
(or from Google Cloud Console). If they don't have it, use the
gws-setup
skill instead.
使用之前设置中的OAuth凭据在另一台机器上安装
gws
。安装完成后将得到一个已认证的CLI,所有agent技能均可直接使用。
前提条件:用户必须拥有来自之前
gws-setup
(或Google Cloud Console)的
client_secret.json
文件。如果没有,请使用
gws-setup
技能替代。

Workflow

操作流程

Step 1: Pre-flight Checks

步骤1:预检查

bash
which gws && gws --version
ls ~/.config/gws/client_secret.json
gws auth status
If already authenticated with the right scopes, skip to Step 4.
bash
which gws && gws --version
ls ~/.config/gws/client_secret.json
gws auth status
如果已使用正确的权限范围完成认证,请直接跳至步骤4。

Step 2: Install the CLI

步骤2:安装CLI

bash
npm install -g @googleworkspace/cli
gws --version
bash
npm install -g @googleworkspace/cli
gws --version

Step 3: Set Up Credentials

步骤3:配置凭据

Ask the user to provide their
client_secret.json
. Three options:
Option A — Paste the JSON content:
Ask the user to paste the JSON. Write it to
~/.config/gws/client_secret.json
:
bash
mkdir -p ~/.config/gws
Expected format:
json
{
  "installed": {
    "client_id": "...",
    "project_id": "...",
    "auth_uri": "https://accounts.google.com/o/oauth2/auth",
    "token_uri": "https://oauth2.googleapis.com/token",
    "client_secret": "...",
    "redirect_uris": ["http://localhost"]
  }
}
Option B — File path:
If the user has the file locally (e.g. in Downloads):
bash
mkdir -p ~/.config/gws
cp /path/to/client_secret.json ~/.config/gws/client_secret.json
Option C — Environment variables:
bash
export GOOGLE_WORKSPACE_CLI_CLIENT_ID="your-client-id"
export GOOGLE_WORKSPACE_CLI_CLIENT_SECRET="your-client-secret"
请用户提供他们的
client_secret.json
文件,有三种方式:
方式A — 粘贴JSON内容:
请用户粘贴JSON内容,将其写入
~/.config/gws/client_secret.json
bash
mkdir -p ~/.config/gws
预期格式:
json
{
  "installed": {
    "client_id": "...",
    "project_id": "...",
    "auth_uri": "https://accounts.google.com/o/oauth2/auth",
    "token_uri": "https://oauth2.googleapis.com/token",
    "client_secret": "...",
    "redirect_uris": ["http://localhost"]
  }
}
方式B — 文件路径:
如果用户本地已有该文件(例如在Downloads文件夹中):
bash
mkdir -p ~/.config/gws
cp /path/to/client_secret.json ~/.config/gws/client_secret.json
方式C — 环境变量:
bash
export GOOGLE_WORKSPACE_CLI_CLIENT_ID="your-client-id"
export GOOGLE_WORKSPACE_CLI_CLIENT_SECRET="your-client-secret"

Step 4: Authenticate

步骤4:完成认证

Ask which Google account to use, then run:
bash
gws auth login --full
Or with specific services to match the original setup:
bash
gws auth login -s gmail,drive,calendar,sheets,docs,chat,tasks
The user can check their original machine's scopes with
gws auth status
to see what was granted.
After browser approval, verify:
bash
gws auth status
询问用户要使用哪个Google账号,然后运行:
bash
gws auth login --full
或者指定与原设置匹配的特定服务:
bash
gws auth login -s gmail,drive,calendar,sheets,docs,chat,tasks
用户可以在原机器上运行
gws auth status
查看已授予的权限范围。
在浏览器中完成授权后,验证认证状态:
bash
gws auth status

Step 5: Install Agent Skills

步骤5:安装Agent技能

bash
npx skills add googleworkspace/cli -g --agent claude-code --all
This installs 90+ skills into
~/.claude/skills/
. Safe to re-run if skills are already installed.
bash
npx skills add googleworkspace/cli -g --agent claude-code --all
此命令会将90+个技能安装到
~/.claude/skills/
目录下。如果技能已安装,重新运行该命令也不会有问题。

Step 6: Verify

步骤6:验证安装

bash
gws auth status
gws calendar +agenda --today
gws gmail +triage

bash
gws auth status
gws calendar +agenda --today
gws gmail +triage

Troubleshooting

故障排查

"Auth error — credentials missing or invalid" (exit code 2)

"Auth error — credentials missing or invalid"(退出码2)

  • Check
    ~/.config/gws/client_secret.json
    exists and has valid JSON
  • Re-run
    gws auth login
  • 检查
    ~/.config/gws/client_secret.json
    文件是否存在且JSON格式有效
  • 重新运行
    gws auth login

Token expired

令牌过期

  • If the GCP app is in "Testing" status, tokens expire after 7 days
  • Re-run
    gws auth login
    to refresh
  • For permanent tokens, push the app to Production in GCP Console OAuth consent screen
  • 如果GCP应用处于“测试”状态,令牌会在7天后过期
  • 重新运行
    gws auth login
    刷新令牌
  • 如需永久令牌,请在GCP控制台的OAuth同意屏幕中将应用发布为正式版

Skills not appearing in Claude Code

技能未在Claude Code中显示

  • Skills load at session start — restart Claude Code after installing
  • Verify:
    ls ~/.claude/skills/gws-* | wc -l
    should show 30+ directories
  • 技能会在会话启动时加载——安装后请重启Claude Code
  • 验证:运行
    ls ~/.claude/skills/gws-* | wc -l
    应显示30+个目录

See Also

相关链接

  • gws-setup — First-time setup including GCP project creation
  • gws-shared — Auth patterns and global flags
  • gws-setup — 首次设置,包括GCP项目创建
  • gws-shared — 认证模式和全局标志