Files
nexus/wiki/concepts/API-Enablement.md
2026-04-21 16:03:27 +08:00

39 lines
1.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
title: "API Enablement"
type: concept
tags: [google-cloud, oauth, api]
---
## Definition
API Enablement 是在 Google Cloud Console 中为项目启用特定 API 服务的操作。即使 OAuth 认证成功,如果目标 API 未启用,调用时仍会返回 `403 accessNotConfigured` 错误。
## Two-Layer Authorization Model
| 层级 | 控制内容 | 错误示例 |
|------|---------|---------|
| 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 工具