gws-install
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseGoogle Workspace CLI — Quick Install
Google Workspace CLI — 快速安装
Install on an additional machine using OAuth credentials from a previous setup. Produces an authenticated CLI with all agent skills ready to use.
gwsPrerequisite: The user must have from a previous (or from Google Cloud Console). If they don't have it, use the skill instead.
client_secret.jsongws-setupgws-setup使用之前设置中的OAuth凭据在另一台机器上安装。安装完成后将得到一个已认证的CLI,所有agent技能均可直接使用。
gws前提条件:用户必须拥有来自之前(或Google Cloud Console)的文件。如果没有,请使用技能替代。
gws-setupclient_secret.jsongws-setupWorkflow
操作流程
Step 1: Pre-flight Checks
步骤1:预检查
bash
which gws && gws --version
ls ~/.config/gws/client_secret.json
gws auth statusIf 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 --versionbash
npm install -g @googleworkspace/cli
gws --versionStep 3: Set Up Credentials
步骤3:配置凭据
Ask the user to provide their . Three options:
client_secret.jsonOption A — Paste the JSON content:
Ask the user to paste the JSON. Write it to :
~/.config/gws/client_secret.jsonbash
mkdir -p ~/.config/gwsExpected 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.jsonOption 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.jsonbash
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 --fullOr with specific services to match the original setup:
bash
gws auth login -s gmail,drive,calendar,sheets,docs,chat,tasksThe user can check their original machine's scopes with to see what was granted.
gws auth statusAfter 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 statusStep 5: Install Agent Skills
步骤5:安装Agent技能
bash
npx skills add googleworkspace/cli -g --agent claude-code --allThis installs 90+ skills into . Safe to re-run if skills are already installed.
~/.claude/skills/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 +triagebash
gws auth status
gws calendar +agenda --today
gws gmail +triageTroubleshooting
故障排查
"Auth error — credentials missing or invalid" (exit code 2)
"Auth error — credentials missing or invalid"(退出码2)
- Check exists and has valid JSON
~/.config/gws/client_secret.json - Re-run
gws auth login
- 检查文件是否存在且JSON格式有效
~/.config/gws/client_secret.json - 重新运行
gws auth login
Token expired
令牌过期
- If the GCP app is in "Testing" status, tokens expire after 7 days
- Re-run to refresh
gws auth login - 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: should show 30+ directories
ls ~/.claude/skills/gws-* | wc -l
- 技能会在会话启动时加载——安装后请重启Claude Code
- 验证:运行应显示30+个目录
ls ~/.claude/skills/gws-* | wc -l
See Also
相关链接
- gws-setup — First-time setup including GCP project creation
- gws-shared — Auth patterns and global flags
- gws-setup — 首次设置,包括GCP项目创建
- gws-shared — 认证模式和全局标志