关于 google-workspace
通过共享 OAuth 2.0 身份验证执行 Gmail 和 Google Calendar 操作,适用于邮件搜索与草稿、日历查询、空闲时间检查及创建日程等工作流。
主要功能
- 01使用共享 OAuth 2.0 凭据认证
- 02搜索并读取 Gmail 邮件
- 03查找待回复邮件并创建草稿
- 04搜索日历并检查空闲时间
- 05创建日历活动
适用场景
- 01查找并阅读需要回复的邮件
- 02准备邮件回复草稿
- 03查询会议时段是否空闲
- 04创建包含参会者的日程
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ letta-ai/ skills --skill google-workspace安装后在 Claude Code 中输入/google-workspace确认已加载。
包含的文件
除 SKILL.md 外,安装时一起下载的参考资料和脚本。
reference/search_operators.mdscripts/calendar_auth.pycreate_draft.pycreate_event.pyfind_busy.pygmail_auth.pylist_calendars.pyneeds_reply.pyread_email.pysearch_emails.pysearch_events.py详细介绍
Google Workspace 集成
通过共享的 OAuth 2.0 身份验证访问 Gmail 和 Google Calendar。
先决条件
- 已安装 Python 3.10+
- 已启用 Gmail API 和 Calendar API 的 Google Cloud 项目
- 已下载 OAuth 2.0 凭据(
credentials.json) - 所需软件包:
google-api-python-client、google-auth-httplib2、google-auth-oauthlib
OAuth 设置
第 1 步:创建 Google Cloud 项目
- 访问 https://console.cloud.google.com/
- 创建新项目或选择现有项目
- 前往 APIs & Services → Library
- 启用 Gmail API 和 Google Calendar API
第 2 步:配置 OAuth 同意屏幕
- 前往 APIs & Services → OAuth consent screen
- 选择 External 用户类型
- 添加以下范围:
https://www.googleapis.com/auth/gmail.readonlyhttps://www.googleapis.com/auth/gmail.composehttps://www.googleapis.com/auth/gmail.modifyhttps://www.googleapis.com/auth/calendar.readonlyhttps://www.googleapis.com/auth/calendar.events
- 添加用户的电子邮件地址作为测试用户
第 3 步:创建 OAuth 凭据
- 前往 APIs & Services → Credentials
- 点击 Create Credentials → OAuth client ID
- 选择 Desktop app 作为应用类型
- 下载 JSON 文件并将其重命名为
credentials.json
第 4 步:安装依赖项
uv add google-api-python-client google-auth-httplib2 google-auth-oauthlib
第 5 步:首次身份验证
运行任意脚本,它会打开浏览器以进行 OAuth 同意。系统会保存 token.json,供以后使用。
Gmail 操作
搜索邮件
uv run python tools/google-workspace/scripts/search_emails.py "from:[email protected]" --credentials ./credentials.json
阅读邮件内容
uv run python tools/google-workspace/scripts/read_email.py <message_id> --credentials ./credentials.json
创建草稿
uv run python tools/google-workspace/scripts/create_draft.py \
--to "[email protected]" \
--subject "Subject line" \
--body "Email body" \
--credentials ./credentials.json
查找需要回复的邮件
uv run python tools/google-workspace/scripts/needs_reply.py --credentials ./credentials.json
Calendar 操作
列出日历
uv run python tools/google-workspace/scripts/list_calendars.py --credentials ./credentials.json
搜索日程
# Search by text
uv run python tools/google-workspace/scripts/search_events.py "meeting" --credentials ./credentials.json
# Search by date range
uv run python tools/google-workspace/scripts/search_events.py --start "2024-01-15" --end "2024-01-20" --credentials ./credentials.json
检查可用时间
uv run python tools/google-workspace/scripts/find_busy.py \
--start "2024-01-15T09:00:00" \
--end "2024-01-15T17:00:00" \
--credentials ./credentials.json
创建日程
uv run python tools/google-workspace/scripts/create_event.py \
--summary "Team Meeting" \
--start "2024-01-15T10:00:00" \
--end "2024-01-15T11:00:00" \
--attendees "[email protected],[email protected]" \
--credentials ./credentials.json
选项: --description、--location、--timezone、--calendar
脚本参考
Gmail:
gmail_auth.py- Gmail 身份验证工具search_emails.py- 使用 Gmail 查询语法搜索收件箱read_email.py- 按邮件 ID 阅读邮件内容create_draft.py- 创建邮件草稿needs_reply.py- 查找等待回复的邮件
Calendar:
calendar_auth.py- Calendar 身份验证工具list_calendars.py- 列出可访问的日历search_events.py- 按文本或日期搜索日程find_busy.py- 检查空闲/忙碌时段create_event.py- 创建日历日程
常见工作流
安排会议
- 搜索日历中的可用时间:
search_events.py --start ... --end ... - 创建日程:
create_event.py --summary "..." --start ... --end ...
回复重要邮件
- 查找需要回复的邮件:
needs_reply.py - 阅读特定邮件:
read_email.py <id> - 创建回复草稿:
create_draft.py --to ... --subject "Re: ..."
评论
支持 Markdown