Auto-sync: 2026-04-21 16:03

This commit is contained in:
2026-04-21 16:03:27 +08:00
parent b3b6be6114
commit 914c8f6925
42 changed files with 3923 additions and 1592 deletions

View File

@@ -1,17 +1,38 @@
---
title: "API Enablement"
type: concept
tags: [google, api, cloud]
sources: []
tags: [google-cloud, oauth, api]
---
## Definition
API EnablementAPI 启用)是 Google Cloud Console 中的操作,允许项目启用特定 API 服务以进行编程访问
API Enablement 是在 Google Cloud Console 中项目启用特定 API 服务的操作。即使 OAuth 认证成功,如果目标 API 未启用,调用时仍会返回 `403 accessNotConfigured` 错误
## Context
- gog CLI 调用 Google API 需要两层配置OAuth 身份认证 + API 启用
- 常见错误 "403 accessNotConfigured" 表示对应 API 未在项目中启用
- 启用 API 后需要 30 秒~2 分钟生效,且需要重新授权以获取新权限
## Two-Layer Authorization Model
## Connections
- [[GOG-CLI-安装配置指南]] ← API 调用前提于 ← [[API-Enablement]]
| 层级 | 控制内容 | 错误示例 |
|------|---------|---------|
| OAuth 授权 | 用户身份认证 | 未授权/权限不足 |
| API Enablement | 是否允许调用 API | `403 accessNotConfigured` |
## 操作步骤
1. 进入 **Google Cloud Console****APIs & Services****Library**
2. 搜索目标 API如 Gmail API、Calendar API
3. 点击 **Enable** 启用
4. 等待生效(通常 30 秒 ~ 2 分钟,有延迟)
5. 重新执行 OAuth 授权(因旧 token 不包含新权限)
## 典型错误
> Gmail API has not been used in project XXX
表示:该 Google Cloud 项目未启用 Gmail API
## 相关概念
- [[OAuth]]:第一层认证
- [[Google-Cloud-Console]]:管理 API 启用的控制台
- [[Gmail-API]]Google Workspace API 示例
- [[Calendar-API]]:日历 API
- [[Drive-API]]:云端硬盘 API
- [[测试用户]]OAuth 授权配置
## 相关工具
- [[gog CLI]]:一个同时需要 OAuth + API Enablement 才能正常工作的 CLI 工具