简介
Google Workspace 官方命令行工具,通过 OAuth 安全集成 Gmail、日历、网盘、表格等全套服务
原始描述
Google Workspace CLI for Gmail, Calendar, Drive, Contacts, Sheets, and Docs.
通过你的 Agent 添加
安装目录:xferops-gog/(目录名取自 SKILL.md 的 frontmatter name,不是 URL 里的 slug)。
点「快速安装」复制一段指令贴给你的 Agent:它会先下载到 /tmp、把文件清单和校验值给你看,你确认之后才解压安装。不会一步装完、也不改系统其它位置。
或者手动安装
包是「根级 SKILL.md + 作者附带的文件」,解压到上面的 <slug>/ 目录即可;
目录名不用换,也不要把包直接解压到 skills 根目录。
技能申请的权限由作者决定:装之前先看清单里有没有脚本、它会读写什么。
中文使用说明 来自收录源
核心功能概览
gog 是专为 Google Workspace 打造的命令行接口工具,覆盖 Gmail、Calendar、Drive、Contacts、Sheets、Docs 六大核心服务。采用 OAuth 2.0 认证体系,用户需通过 gog auth credentials 和 gog auth add 完成一次性授权配置,即可在终端实现邮件检索发送、日历事件管理、电子表格操作等全流程自动化。
显著优势
- 原生集成深度:直接调用 Google 官方 API,支持邮件线程/单消息双模式检索、日历颜色定制、Sheets 行列精准操作等高级功能
- 自动化友好:全命令行设计配合
--json输出,完美适配 Shell 脚本和 CI/CD 流水线;支持环境变量预设账户(GOG_ACCOUNT)和无人值守模式(GOG_KEYRING_PASSWORD) - 灵活的内容处理:邮件支持纯文本/HTML/文件/stdin 四种输入方式,Sheets 支持 JSON 批量写入,Docs 支持多格式导出
- 开发者体验:Brew 一键安装,内置帮助完善,错误提示清晰
潜在局限与风险
- OAuth 配置门槛:首次使用需从 Google Cloud Console 创建 OAuth 应用并下载
client_secret.json,对非技术用户形成障碍 - 权限范围宽泛:需授予 Gmail 读写、日历管理、网盘访问等敏感权限,虽符合最小必要原则,但用户需充分理解授权含义
- 无实时同步机制:纯请求-响应模式,不具备像官方客户端那样的实时推送或冲突自动解决能力
- Docs 编辑受限:仅支持导出/读取,不支持直接编辑文档内容
- 账户锁定风险:高频 API 调用可能触发 Google 速率限制,自动化脚本需自行实现退避重试
适合人群
系统管理员、DevOps 工程师、数据自动化从业者、需要批量处理 Google Workspace 数据的技术用户。特别适合需要在没有图形界面的服务器(EC2、容器)上操作 Google 服务的场景。
安全注意事项
- 密钥保管:
client_secret.json和GOG_KEYRING_PASSWORD属于高敏感凭证,需按生产密钥标准管理(Vault、AWS Secrets Manager 等) - Token 存储:默认使用系统钥匙串(macOS Keychain、Linux Secret Service),headless 环境建议改用文件钥匙环并加密存储
- 最小权限实践:授权时按需勾选服务(
--services gmail,calendar),避免全开
技能正文
name: xferops-gog description: Google Workspace CLI for Gmail, Calendar, Drive, Contacts, Sheets, and Docs. homepage: https://gogcli.sh metadata: { "openclaw": { "emoji": "🎮", "requires": { "bins": ["gog"] }, "install": [ { "id": "brew", "kind": "brew", "formula": "steipete/tap/gogcli", "bins": ["gog"], "label": "Install gog (brew)", }, ], }, }
gog
Use gog for Gmail/Calendar/Drive/Contacts/Sheets/Docs. Requires OAuth setup.
Setup (once)
gog auth credentials /path/to/client_secret.jsongog auth add you@gmail.com --services gmail,calendar,drive,contacts,docs,sheetsgog auth list
Common commands
- Gmail search:
gog gmail search 'newer_than:7d' --max 10 - Gmail messages search (per email, ignores threading):
gog gmail messages search "in:inbox from:ryanair.com" --max 20 --account you@example.com - Gmail read email body:
gog gmail get <MESSAGE_ID> --account you@example.com- Get message ID from search, then use
getto fetch full body - Use
--format metadatafor just headers,--format rawfor raw RFC822
- Get message ID from search, then use
- Gmail attachments:
gog gmail attachment <messageId> <attachmentId> --out /path/to/save - Gmail send (plain):
gog gmail send --to a@b.com --subject "Hi" --body "Hello" - Gmail send (multi-line):
gog gmail send --to a@b.com --subject "Hi" --body-file ./message.txt - Gmail send (stdin):
gog gmail send --to a@b.com --subject "Hi" --body-file - - Gmail send (HTML):
gog gmail send --to a@b.com --subject "Hi" --body-html "<p>Hello</p>" - Gmail draft:
gog gmail drafts create --to a@b.com --subject "Hi" --body-file ./message.txt - Gmail send draft:
gog gmail drafts send <draftId> - Gmail reply:
gog gmail send --to a@b.com --subject "Re: Hi" --body "Reply" --reply-to-message-id <msgId> - Calendar list events:
gog calendar events <calendarId> --from <iso> --to <iso> - Calendar create event:
gog calendar create <calendarId> --summary "Title" --from <iso> --to <iso> - Calendar create with color:
gog calendar create <calendarId> --summary "Title" --from <iso> --to <iso> --event-color 7 - Calendar update event:
gog calendar update <calendarId> <eventId> --summary "New Title" --event-color 4 - Calendar show colors:
gog calendar colors - Drive search:
gog drive search "query" --max 10 - Contacts:
gog contacts list --max 20 - Sheets get:
gog sheets get <sheetId> "Tab!A1:D10" --json - Sheets update:
gog sheets update <sheetId> "Tab!A1:B2" --values-json '[["A","B"],["1","2"]]' --input USER_ENTERED - Sheets append:
gog sheets append <sheetId> "Tab!A:C" --values-json '[["x","y","z"]]' --insert INSERT_ROWS - Sheets clear:
gog sheets clear <sheetId> "Tab!A2:Z" - Sheets metadata:
gog sheets metadata <sheetId> --json - Docs export:
gog docs export <docId> --format txt --out /tmp/doc.txt - Docs cat:
gog docs cat <docId>
Calendar Colors
- Use
gog calendar colorsto see all available event colors (IDs 1-11) - Add colors to events with
--event-color <id>flag - Event color IDs (from
gog calendar colorsoutput):- 1: #a4bdfc
- 2: #7ae7bf
- 3: #dbadff
- 4: #ff887c
- 5: #fbd75b
- 6: #ffb878
- 7: #46d6db
- 8: #e1e1e1
- 9: #5484ed
- 10: #51b749
- 11: #dc2127
Email Formatting
-
Prefer plain text. Use
--body-filefor multi-paragraph messages (or--body-file -for stdin). -
Same
--body-filepattern works for drafts and replies. -
--bodydoes not unescape\n. If you need inline newlines, use a heredoc or$'Line 1\n\nLine 2'. -
Use
--body-htmlonly when you need rich formatting. -
HTML tags:
<p>for paragraphs,<br>for line breaks,<strong>for bold,<em>for italic,<a href="url">for links,<ul>/<li>for lists. -
Example (plain text via stdin):
gog gmail send --to recipient@example.com \ --subject "Meeting Follow-up" \ --body-file - <<'EOF' Hi Name, Thanks for meeting today. Next steps: - Item one - Item two Best regards, Your Name EOF -
Example (HTML list):
gog gmail send --to recipient@example.com \ --subject "Meeting Follow-up" \ --body-html "<p>Hi Name,</p><p>Thanks for meeting today. Here are the next steps:</p><ul><li>Item one</li><li>Item two</li></ul><p>Best regards,<br>Your Name</p>"
Notes
Headless/EC2 setup: On headless machines (no TTY), gog needs GOG_KEYRING_PASSWORD set:
-
Add to shell profile:
export GOG_KEYRING_PASSWORD=your-password -
Add to systemd service:
Environment=GOG_KEYRING_PASSWORD=your-password -
Or use file keyring:
gog auth keyring file -
Set
GOG_ACCOUNT=you@gmail.comto avoid repeating--account. -
For scripting, prefer
--jsonplus--no-input. -
Sheets values can be passed via
--values-json(recommended) or as inline rows. -
Docs supports export/cat/copy. In-place edits require a Docs API client (not in gog).
-
Confirm before sending mail or creating events.
-
gog gmail searchreturns one row per thread; usegog gmail messages searchwhen you need every individual email returned separately.
正文来自原始发布页, 版权归作者所有,许可未标注。 权利人认为有不妥,可申请下架。