Auto-sync: 2026-04-28 12:03
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
---
|
||||
title: "GOG CLI 安装配置指南"
|
||||
type: source
|
||||
tags: [gog, gog-cli, macos, google-workspace]
|
||||
tags: [gog, gog-cli, macos, google-workspace, oauth]
|
||||
date: 2026-03-15
|
||||
---
|
||||
|
||||
@@ -9,37 +9,39 @@ date: 2026-03-15
|
||||
- [[raw/Skills/GOG-CLI-安装配置指南.md]]
|
||||
|
||||
## Summary(用中文描述)
|
||||
- 核心主题:gog CLI(Google Workspace 命令行工具)在 macOS 系统上的完整安装与配置流程
|
||||
- 问题域:如何通过命令行管理 Google Workspace 全套服务(Gmail、Google Calendar、Google Drive、Google Contacts、Google Docs、Google Sheets),并与 AI Agent 工作流集成
|
||||
- 方法/机制:Homebrew 安装 → Google Cloud Console 创建 OAuth 凭证 → 移动凭证文件到 gogcli 配置目录 → 添加测试用户解除 Google 安全限制 → 启用各 Google API → 验证授权状态
|
||||
- 结论/价值:实现通过命令行管理 Google Workspace 全套服务的能力,可集成到 AI Agent 工作流中(自动邮件处理、日历管理等)
|
||||
- 核心主题:gog CLI 工具在 macOS 上的完整安装与配置流程
|
||||
- 问题域:Google Workspace(Gmail、Google Calendar、Google Drive、Google Contacts、Google Docs、Google Sheets)的命令行管理
|
||||
- 方法/机制:通过 Homebrew 安装 → Google Cloud Console 创建 OAuth 凭证 → 配置凭证文件 → 添加测试用户绕过 Google 安全验证 → 启用各 Google API → 验证授权
|
||||
- 结论/价值:实现通过命令行高效管理 Google Workspace 全套服务,支持搜索邮件、发送邮件、管理日历、搜索 Drive 文件、操作 Sheets/Docs 等功能
|
||||
|
||||
## Key Claims(用中文描述)
|
||||
- Homebrew 可通过 `brew install steipete/tap/gogcli` 一键安装 gog CLI,输出路径为 `/opt/homebrew/bin/gog`
|
||||
- OAuth 凭证需要放置在 `/Users/weishen/Library/Application Support/gogcli/credentials.json`,并通过 `gog auth credentials` 命令指定路径
|
||||
- 首次授权时 Google 会阻止未验证应用,需要在 Google Cloud Console 的 OAuth 客户端中将测试用户邮箱加入白名单才能通过授权
|
||||
- Google API 调用需要同时满足两个条件:OAuth 授权成功 + API 已启用(Enabling),缺一不可
|
||||
- 启用新的 API 服务后需要重新授权(`gog auth revoke` + `gog auth login`),因为旧 token 不包含新权限
|
||||
- 通过 Homebrew 安装 gog CLI 是最简方式,安装路径为 /opt/homebrew/bin/gog
|
||||
- Google API 调用需同时满足 OAuth 授权和 API Enablement 两层条件,缺一不可
|
||||
- 对于未经 Google 验证的应用,通过在 OAuth 客户端中添加测试用户可绕过"此应用未经 Google 验证"的安全限制
|
||||
- 启用新 API 服务后需重新授权(revoke + login),否则旧 token 不包含新权限会导致 403 错误
|
||||
- 设置 GOG_ACCOUNT 环境变量可避免每次命令都需指定账号
|
||||
|
||||
## Key Quotes
|
||||
> "此应用未经 Google 验证。此应用请求访问您 Google 账号中的敏感信息。在开发者让该应用通过 Google 验证之前,请勿使用该应用。" — Google 首次授权时的安全警告,解决方案是在测试用户中添加 Google 邮箱
|
||||
> "即使 OAuth 成功,如果 API 未启用也会报错:403 accessNotConfigured" — API 调用失败的常见原因
|
||||
> "旧 token 不包含新权限" — 启用新 API 后必须重新授权的原因
|
||||
> "此应用未经 Google 验证。此应用请求访问您 Google 账号中的敏感信息。在开发者让该应用通过 Google 验证之前,请勿使用该应用。" — 首次授权时的典型 Google 安全警告
|
||||
> "即使 OAuth 成功,如果 API 未启用也会报错:403 accessNotConfigured" — OAuth 与 API Enablement 的两层机制说明
|
||||
> "gog auth revoke → gog auth login:旧 token 不包含新权限" — 启用新 API 后的必要重新授权步骤
|
||||
|
||||
## Key Concepts
|
||||
- [[OAuth 2.0]]:Google 账号身份认证协议,gog CLI 使用 OAuth 完成用户授权
|
||||
- [[Google Cloud Console]]:Google API 管理平台,用于创建 OAuth 凭证和启用 API 服务
|
||||
- [[Google Workspace]]:Google 办公套件,包含 Gmail、Google Calendar、Google Drive、Google Contacts、Google Docs、Google Sheets
|
||||
- [[Google API Enablement]]:Google API 调用需要先在 Google Cloud Console 中启用对应服务,与 OAuth 认证是两层独立机制
|
||||
- [[OAuth 2.0]]:Google API 的用户身份认证机制,gog 通过 OAuth 让用户授权 CLI 访问其 Google 账号数据
|
||||
- [[Google Cloud Console]]:Google 云平台控制台,用于创建 OAuth 凭证和启用 Google API 服务
|
||||
- [[Google Workspace]]:Google 生产力工具套件,包含 Gmail、Google Calendar、Google Drive、Google Contacts、Google Docs、Google Sheets
|
||||
- [[Homebrew]]:macOS 包管理器,gog CLI 通过 `brew install steipete/tap/gogcli` 安装
|
||||
|
||||
## Key Entities
|
||||
- [[gog CLI]]:由 steipete 开发的 Google Workspace 命令行管理工具,通过 Homebrew 分发
|
||||
- [[Google Cloud Console]]:Google 云平台控制台,用于管理 OAuth 凭证和 API 启用状态
|
||||
- [[steipete]]:gogcli 项目的开发者,维护 gog CLI 工具
|
||||
- [[ishenwei@gmail.com]]:配置中使用的 Google 账号,通过该账号授权 gog 访问 Google Workspace
|
||||
|
||||
## Connections
|
||||
- [[personal-crm]] ← uses ← [[gog CLI]](gog CLI 提供 Gmail 和 Calendar 数据,是 personal-crm 的前置依赖)
|
||||
- [[gog CLI]] ← requires ← [[OAuth 2.0]](认证机制)
|
||||
- [[gog CLI]] ← requires ← [[Google API Enablement]](每项服务需单独启用)
|
||||
- [[Homebrew]] ← 安装工具 ← [[GOG CLI 安装配置指南]]
|
||||
- [[Google Workspace]] ← 管理对象 ← [[GOG CLI 安装配置指南]]
|
||||
- [[OAuth 2.0]] ← 认证机制 ← [[GOG CLI 安装配置指南]]
|
||||
- [[Google Cloud Console]] ← 配置平台 ← [[GOG CLI 安装配置指南]]
|
||||
|
||||
## Contradictions
|
||||
- 无已知冲突内容
|
||||
- 暂无已知冲突内容
|
||||
|
||||
|
||||
Reference in New Issue
Block a user