46 lines
3.1 KiB
Markdown
46 lines
3.1 KiB
Markdown
---
|
||
title: "GOG CLI 安装配置指南"
|
||
type: source
|
||
tags: [gog, gog-cli, macos, google-workspace]
|
||
date: 2026-03-15
|
||
---
|
||
|
||
## Source File
|
||
- [[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 工作流中(自动邮件处理、日历管理等)
|
||
|
||
## 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 不包含新权限
|
||
|
||
## Key Quotes
|
||
> "此应用未经 Google 验证。此应用请求访问您 Google 账号中的敏感信息。在开发者让该应用通过 Google 验证之前,请勿使用该应用。" — Google 首次授权时的安全警告,解决方案是在测试用户中添加 Google 邮箱
|
||
> "即使 OAuth 成功,如果 API 未启用也会报错:403 accessNotConfigured" — API 调用失败的常见原因
|
||
> "旧 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 认证是两层独立机制
|
||
|
||
## Key Entities
|
||
- [[gog CLI]]:由 steipete 开发的 Google Workspace 命令行管理工具,通过 Homebrew 分发
|
||
- [[Google Cloud Console]]:Google 云平台控制台,用于管理 OAuth 凭证和 API 启用状态
|
||
|
||
## Connections
|
||
- [[personal-crm]] ← uses ← [[gog CLI]](gog CLI 提供 Gmail 和 Calendar 数据,是 personal-crm 的前置依赖)
|
||
- [[gog CLI]] ← requires ← [[OAuth 2.0]](认证机制)
|
||
- [[gog CLI]] ← requires ← [[Google API Enablement]](每项服务需单独启用)
|
||
|
||
## Contradictions
|
||
- 无已知冲突内容
|