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

@@ -0,0 +1,38 @@
---
title: "Gmail API"
type: concept
tags: [google-workspace, api, email]
---
## Definition
Gmail API 是 Google 提供的编程接口,允许第三方应用程序通过 OAuth 2.0 认证访问 Gmail 邮件服务,实现搜索、读取、发送、管理邮件等功能。
## Key Operations
| 操作 | 描述 |
|------|------|
| messages.list | 列出邮件列表 |
| messages.get | 获取邮件详情 |
| messages.send | 发送邮件 |
| messages.modify | 修改邮件标签 |
| drafts.create | 创建草稿 |
| drafts.send | 发送草稿 |
## Prerequisites for Access
1. **Google Cloud Console** 中启用 Gmail API
2. 配置 **OAuth 2.0 凭证**(桌面应用类型)
3. 用户完成 OAuth 授权流程
4. 添加**测试用户**(未验证应用场景)
## Common Error
- `403 accessNotConfigured`API 未在 Google Cloud Console 中启用
- `403 accessDenied`:用户未完成 OAuth 授权
## Related Concepts
- [[OAuth]]:认证机制
- [[Google-Cloud-Console]]:凭证配置
- [[测试用户]]:绕过未验证应用限制
- [[API-Enablement]]:启用 API 的操作
## Related Entities
- [[Google]]API 提供方
- [[gog CLI]]:使用 Gmail API 的命令行工具