book-google-meet
Create scheduled Google Calendar events with OPEN access Google Meet spaces.
Quick Start
CODEBLOCK0
Prerequisites
1. Google Cloud Project Setup
- 1. Go to Google Cloud Console
- Create a new project
- Enable APIs:
-
Google Calendar API
-
Google Meet API
2. OAuth Consent Screen
- 1. Go to OAuth consent screen
- Select External user type
- Fill in app name and contact email
- Add scope: INLINECODE0
- Set publishing status to In production
3. Create OAuth Credentials
- 1. Go to Credentials
- Click Create Credentials → OAuth client ID
- Select Desktop app application type
- Download JSON and save as INLINECODE1
Alternative: Set environment variables instead of using client_secrets.json:
CODEBLOCK1
Required OAuth Scopes
CODEBLOCK2
Note: Use meetings.space.settings (non-sensitive) instead of meetings.space.created (sensitive).
Usage
Basic Usage
CODEBLOCK3
With Attendees
CODEBLOCK4
With Description
CODEBLOCK5
Access Types
CODEBLOCK6
Command Line Options
| Option | Description | Default |
|---|
| INLINECODE4 , INLINECODE5 | Meeting title (required) | - |
| INLINECODE6 , INLINECODE7 |
Meeting date (YYYY-MM-DD) | - |
|
--time | Meeting start time (HH:MM) | - |
|
--duration | Duration in minutes | 45 |
|
--timezone,
-z | Timezone | America/New_York |
|
--attendees | Comma-separated email list | - |
|
--description | Meeting description | - |
|
--access-type | OPEN, TRUSTED, or RESTRICTED | OPEN |
|
--credentials,
-c | Path to client
secrets.json | clientsecrets.json |
|
--token-path | Path to store OAuth token | meeting_token.pickle |
Output Example
CODEBLOCK7
How It Works
- 1. Calendar API - Create event with Meet conference
- Meet API (spaces.get) - Look up Meet space using meeting code
- Meet API (spaces.patch) - Update space to set INLINECODE18
Troubleshooting
403 Permission Denied
Cause: Using meetings.space.created scope (sensitive) without additional verification.
Solution: Use meetings.space.settings scope (non-sensitive) instead. Already fixed in the script.
API Not Enabled
Enable both APIs in Google Cloud Console:
- - Calendar API: https://console.developers.google.com/apis/api/calendar.googleapis.com/overview
- Meet API: https://console.developers.google.com/apis/api/meet.googleapis.com/overview
Invalid Credentials
Delete meeting_token.pickle to force re-authentication:
CODEBLOCK8
Files
- -
book_meeting.py - Main script - INLINECODE23 - OAuth credentials (you provide)
- INLINECODE24 - Cached OAuth token (auto-generated)
- INLINECODE25 - Python dependencies
Security Notes
⚠️ Sensitive Files:
| File | Description | Security |
|---|
| INLINECODE26 | Cached OAuth tokens (contains refresh token) | Keep secure; delete when not needed; do not commit to version control |
| INLINECODE27 |
OAuth client credentials | Never commit to version control; protect as password |
⚠️ Token File Warning:
The script writes meeting_token.pickle to disk after first OAuth authorization. This file contains sensitive OAuth tokens including refresh tokens that can be used to access your Google account. Protect this file:
- - Do not share it
- Do not commit it to version control
- Delete it when no longer needed
- Ensure proper file permissions (readable only by owner)
References
book-google-meet
创建具有开放访问权限的 Google Meet 空间的定时 Google 日历事件。
快速开始
bash
1. 安装依赖
pip install -r requirements.txt
2. 从 Google Cloud Console 获取 OAuth 凭据
- 启用 Google Calendar API 和 Google Meet API
- 创建 OAuth 2.0 桌面应用凭据
- 下载 client_secrets.json
3. 将 client_secrets.json 放置在技能目录中
4. 运行脚本
python book_meeting.py --title 我的会议 --date 2026-03-12 --time 15:00 --duration 45 --timezone Asia/Shanghai
前提条件
1. Google Cloud 项目设置
- 1. 前往 Google Cloud Console
- 创建一个新项目
- 启用 API:
-
Google Calendar API
-
Google Meet API
2. OAuth 同意屏幕
- 1. 前往 OAuth 同意屏幕
- 选择外部用户类型
- 填写应用名称和联系邮箱
- 添加范围:https://www.googleapis.com/auth/meetings.space.settings
- 将发布状态设置为生产环境
3. 创建 OAuth 凭据
- 1. 前往 凭据
- 点击创建凭据 → OAuth 客户端 ID
- 选择桌面应用类型
- 下载 JSON 并保存为 clientsecrets.json
替代方案: 使用环境变量代替 client_secrets.json:
bash
export GOOGLECLIENTID=your-client-id
export GOOGLECLIENTSECRET=your-client-secret
必需的 OAuth 范围
https://www.googleapis.com/auth/calendar.events
https://www.googleapis.com/auth/calendar
https://www.googleapis.com/auth/meetings.space.settings
注意: 使用 meetings.space.settings(非敏感)而不是 meetings.space.created(敏感)。
使用方法
基本用法
bash
python book_meeting.py --title 团队会议 --date 2026-03-12 --time 15:00 --duration 45 --timezone Asia/Shanghai
带参与者
bash
python book_meeting.py --title 团队会议 --date 2026-03-12 --time 15:00 --duration 45 \
--timezone Asia/Shanghai \
--attendees user1@example.com,user2@example.com
带描述
bash
python book_meeting.py --title 团队会议 --date 2026-03-12 --time 15:00 --duration 45 \
--timezone Asia/Shanghai \
--description 每周同步会议
访问类型
bash
OPEN - 拥有链接的任何人都可以加入(默认)
python book_meeting.py --title 公开会议 --date 2026-03-12 --time 15:00 --duration 45 \
--timezone Asia/Shanghai --access-type OPEN
TRUSTED - 组织成员 + 受邀外部用户
python book_meeting.py --title 内部会议 --date 2026-03-12 --time 15:00 --duration 45 \
--timezone Asia/Shanghai --access-type TRUSTED
RESTRICTED - 仅限受邀者
python book_meeting.py --title 私人会议 --date 2026-03-12 --time 15:00 --duration 45 \
--timezone Asia/Shanghai --access-type RESTRICTED
命令行选项
| 选项 | 描述 | 默认值 |
|---|
| --title, -t | 会议标题(必需) | - |
| --date, -d |
会议日期(YYYY-MM-DD) | - |
| --time | 会议开始时间(HH:MM) | - |
| --duration | 持续时间(分钟) | 45 |
| --timezone, -z | 时区 | America/New_York |
| --attendees | 逗号分隔的邮箱列表 | - |
| --description | 会议描述 | - |
| --access-type | OPEN、TRUSTED 或 RESTRICTED | OPEN |
| --credentials, -c | client
secrets.json 的路径 | clientsecrets.json |
| --token-path | 存储 OAuth 令牌的路径 | meeting_token.pickle |
输出示例
🚀 步骤 1:创建带 Meet 会议的日历事件...
✅ 日历事件已创建,包含 Meet 会议
会议代码:abc-defg-hij
🚀 步骤 2:使用会议代码查找 Meet 空间...
✅ 找到 Meet 空间:spaces/xxxxxxxxxx
🚀 步骤 3:将 Meet 空间修补为 OPEN 访问...
✅ Meet 空间修补成功!
访问类型:OPEN
============================================================
✅ 会议创建成功!
============================================================
📅 标题:团队会议
🕐 开始:2026-03-12T15:00:00
🕐 结束:2026-03-12T15:45:00
🌐 时区:Asia/Shanghai
🔗 Meet 链接:https://meet.google.com/abc-defg-hij
📞 会议代码:abc-defg-hij
🔓 访问类型:OPEN
🆔 空间名称:spaces/xxxxxxxxxx
📧 日历链接:https://calendar.google.com/calendar/event?eid=...
🆔 事件 ID:xxxxxxxxxxxxxx
============================================================
工作原理
- 1. Calendar API - 创建带 Meet 会议的事件
- Meet API (spaces.get) - 使用会议代码查找 Meet 空间
- Meet API (spaces.patch) - 更新空间以设置 accessType=OPEN
故障排除
403 权限被拒绝
原因: 使用 meetings.space.created 范围(敏感)而未进行额外验证。
解决方案: 改用 meetings.space.settings 范围(非敏感)。脚本中已修复。
API 未启用
在 Google Cloud Console 中启用两个 API:
- - Calendar API:https://console.developers.google.com/apis/api/calendar.googleapis.com/overview
- Meet API:https://console.developers.google.com/apis/api/meet.googleapis.com/overview
凭据无效
删除 meeting_token.pickle 以强制重新认证:
bash
rm meeting_token.pickle
文件
- - bookmeeting.py - 主脚本
- clientsecrets.json - OAuth 凭据(您提供)
- meeting_token.pickle - 缓存的 OAuth 令牌(自动生成)
- requirements.txt - Python 依赖项
安全说明
⚠️ 敏感文件:
| 文件 | 描述 | 安全 |
|---|
| meetingtoken.pickle | 缓存的 OAuth 令牌(包含刷新令牌) | 保持安全;不需要时删除;不要提交到版本控制 |
| clientsecrets.json |
OAuth 客户端凭据 | 切勿提交到版本控制;像密码一样保护 |
⚠️ 令牌文件警告:
脚本在首次 OAuth 授权后将 meeting_token.pickle 写入磁盘。此文件包含敏感的 OAuth 令牌,包括可用于访问您 Google 账户的刷新令牌。保护此文件:
- - 不要共享
- 不要提交到版本控制
- 不再需要时删除
- 确保适当的文件权限(仅所有者可读)
参考