You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何通过Google Calendar API获取关联日历对应的电子邮箱地址

Google Calendar API 获取日历绑定邮箱实现方案

你查询的Calendars资源接口本身不返回日历绑定邮箱字段,该信息归属在CalendarList资源下,按以下步骤实现即可:

  • 确保你的应用申请了calendar.readonly或更高权限,该权限是读取CalendarList资源的必要前提
  • 调用calendarList.get接口,传入目标日历的ID作为入参
  • 接口返回结果中的id字段就是该日历绑定的电子邮箱:主日历的ID默认与用户谷歌账号邮箱完全一致,辅助日历、共享日历的ID也为标准邮箱格式

如果你需要批量拉取当前授权用户所有关联日历的绑定邮箱,可以调用calendarList.list接口,遍历返回结果中的items数组,逐一取每个元素的id字段即可。

代码示例(Node.js 客户端)

// 已完成OAuth2授权初始化的前提下
const calendar = google.calendar({ version: 'v3', auth: oauth2Client });

// 单个日历查询
const singleRes = await calendar.calendarList.get({
  calendarId: '目标日历ID'
});
console.log('当前日历绑定邮箱:', singleRes.data.id);

// 批量查询所有关联日历
const listRes = await calendar.calendarList.list();
listRes.data.items.forEach(item => {
  console.log(`日历${item.summary}绑定邮箱:${item.id}`);
});

内容的提问来源于stack exchange,提问作者figalo66

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.26 10:54:00