Google 日历 API 不要 return 共享日历
Google Calendar API don't return shared calendars
初始情况:
- 在我们的一项服务中,我们使用服务帐户调用 Google 日历 API。
- 用户可以通过其技术电子邮件地址与该技术帐户共享他们的日历
(@.iam.gserviceaccount.com).
- 由于日历是共享的,我们可以通过API查询它们(CalendarList/List:https://developers.google.com/calendar/v3/reference/calendarList/list)
- 所有这一切在几年内都没有问题。
当前问题:
- 正如我们最近发现的那样,新共享的日历不再通过 API 调用返回。过去共享的日历仍会返回 (!)
- 我们知道 pageTokens 并处理它们 - 这不是问题。对于一个(测试)帐户,当前仅共享 8 个日历,我们无法获取更多。
- 后端调用时没有error/warning
- 在 Google 开发者控制台上没有 error/warning/quota 问题
我们还没有从 Google 收到任何关于我们帐户的日历 API 更改或限制的 warning/alert。此外,我还没有发现任何关于 Google 日历的公开 issue/outage。
可能是什么问题?
我应该向 Google 报告吗?如果是,具体如何?我所能找到的只是一个 "Google Cloud Platform Free Trial Troubleshooter",其中(除了建议使用 Whosebug ;])我可以用 "specific question and technical support" 做的就是 "start a chat",这会导致内部 Google 网站 (moma)。还有什么我可以尝试的吗?
如有任何帮助,我们将不胜感激!
更新:
官方文档中有间接 trace/hint Google 改变了这种(自动)接受共享日历的行为 - 比较 "Share an existing calendar" 部分的当前版本和 2019 年 8 月的版本:
- https://support.google.com/calendar/answer/37082?hl=en
- https://web.archive.org/web/20190904092735/https://support.google.com/calendar/answer/37082?hl=en
更新 2
感谢@DaImTo(需要 google 帐户),我已设法将此问题报告给 Google:
https://issuetracker.google.com/issues/148804709
重点如下:
- "Due to a recent change of behaviour, any account has to explicitly "接受“已与他们共享的日历。”
- 状态:不会修复(预期行为)
CalendarList.List Returns the calendars on the user's calendar list.
这不一定是用户有权访问的所有日历。用户日历列表显示在 google 日历网络应用
的左下角
当用户被授予对新日历的访问权限时,他们会通过电子邮件接受访问权限。当他们这样做时,日历通常会添加到他们的 calendarlist.list。服务帐户不会发生这种情况,因为它无法查看电子邮件并接受它只有访问权限的邀请。
如果您希望将日历添加到服务帐户日历列表中,则需要通过服务帐户插入它们。使用 calendarlist.insert
我不确定为什么你认为这在过去有效,我已经使用这个 api 多年,并且出于这个原因从不使用带有服务帐户的 calenadarlist。
- User shares his/hers calendar with the email of the service account 2. Executing CalendarList/List, we expect to return all calendars, including the one shared in step 1 Situation is, that the API call returns only "earlier shared" calendars, but not the one we share now. I hope I clarified the bits - if not, please ask specific questions, thank you!
没有任何方法可以 return 用户有权访问的所有日历。 TBH 考虑到所有 public 日历在野外的反应将是巨大的,它们也会被 returned。
使用服务帐户的提示。
服务帐户并非旨在让您提供给用户让他们授予其日历访问权限。服务帐户旨在为您开发人员提供一个静态日历,您可以在您的应用程序中使用该日历并将数据保存到其中。
如果您正在访问用户日历,那么当您需要在他们离线时访问他们的数据时,您应该使用 Oauth2 并保存刷新令牌。
报告问题
最近围绕服务帐户和 google 日历发生了很多变化 我自己在过去几个月中报告了 servral 问题 issue forum 我建议您将此作为问题提交。 Link 在这里,我会看看我是否可以找到我在那个团队的联系人来解决这个问题。
最近有变化
与用户/服务帐户共享日历后,该用户/服务帐户必须通过将共享日历添加到他的日历列表来"accept"共享。
这可以通过单击 "Add this calendar" 从 UI 中完成(如果是用户),也可以使用方法 CalendarList: insert 以编程方式(对用户和服务帐户均有效) .
另一种解决方案是
1) 将日历添加到您的 Google 帐户
2) 与服务帐户电子邮件 ID 共享日历
3) 转到新创建的日历中的设置和共享,然后找到日历 ID
4) 按照这个 Link - https://developers.google.com/calendar/v3/reference/calendarList/insert
这是示例 PHP 用于在服务帐户中添加现有日历的代码
$calendarListEntry = new Google_Service_Calendar_CalendarListEntry();
$calendarListEntry->setId("calendarId");
$createdCalendarListEntry = $service->calendarList->insert($calendarListEntry);
echo $createdCalendarListEntry->getSummary();
5) 现在调用日历列表API,您会在服务帐户日历列表
中找到添加的日历ID
初始情况:
- 在我们的一项服务中,我们使用服务帐户调用 Google 日历 API。
- 用户可以通过其技术电子邮件地址与该技术帐户共享他们的日历 (@.iam.gserviceaccount.com).
- 由于日历是共享的,我们可以通过API查询它们(CalendarList/List:https://developers.google.com/calendar/v3/reference/calendarList/list)
- 所有这一切在几年内都没有问题。
当前问题:
- 正如我们最近发现的那样,新共享的日历不再通过 API 调用返回。过去共享的日历仍会返回 (!)
- 我们知道 pageTokens 并处理它们 - 这不是问题。对于一个(测试)帐户,当前仅共享 8 个日历,我们无法获取更多。
- 后端调用时没有error/warning
- 在 Google 开发者控制台上没有 error/warning/quota 问题
我们还没有从 Google 收到任何关于我们帐户的日历 API 更改或限制的 warning/alert。此外,我还没有发现任何关于 Google 日历的公开 issue/outage。
可能是什么问题?
我应该向 Google 报告吗?如果是,具体如何?我所能找到的只是一个 "Google Cloud Platform Free Trial Troubleshooter",其中(除了建议使用 Whosebug ;])我可以用 "specific question and technical support" 做的就是 "start a chat",这会导致内部 Google 网站 (moma)。还有什么我可以尝试的吗?
如有任何帮助,我们将不胜感激!
更新: 官方文档中有间接 trace/hint Google 改变了这种(自动)接受共享日历的行为 - 比较 "Share an existing calendar" 部分的当前版本和 2019 年 8 月的版本:
- https://support.google.com/calendar/answer/37082?hl=en
- https://web.archive.org/web/20190904092735/https://support.google.com/calendar/answer/37082?hl=en
更新 2 感谢@DaImTo(需要 google 帐户),我已设法将此问题报告给 Google: https://issuetracker.google.com/issues/148804709
重点如下:
- "Due to a recent change of behaviour, any account has to explicitly "接受“已与他们共享的日历。”
- 状态:不会修复(预期行为)
CalendarList.List Returns the calendars on the user's calendar list.
这不一定是用户有权访问的所有日历。用户日历列表显示在 google 日历网络应用
的左下角当用户被授予对新日历的访问权限时,他们会通过电子邮件接受访问权限。当他们这样做时,日历通常会添加到他们的 calendarlist.list。服务帐户不会发生这种情况,因为它无法查看电子邮件并接受它只有访问权限的邀请。
如果您希望将日历添加到服务帐户日历列表中,则需要通过服务帐户插入它们。使用 calendarlist.insert
我不确定为什么你认为这在过去有效,我已经使用这个 api 多年,并且出于这个原因从不使用带有服务帐户的 calenadarlist。
- User shares his/hers calendar with the email of the service account 2. Executing CalendarList/List, we expect to return all calendars, including the one shared in step 1 Situation is, that the API call returns only "earlier shared" calendars, but not the one we share now. I hope I clarified the bits - if not, please ask specific questions, thank you!
没有任何方法可以 return 用户有权访问的所有日历。 TBH 考虑到所有 public 日历在野外的反应将是巨大的,它们也会被 returned。
使用服务帐户的提示。
服务帐户并非旨在让您提供给用户让他们授予其日历访问权限。服务帐户旨在为您开发人员提供一个静态日历,您可以在您的应用程序中使用该日历并将数据保存到其中。
如果您正在访问用户日历,那么当您需要在他们离线时访问他们的数据时,您应该使用 Oauth2 并保存刷新令牌。
报告问题
最近围绕服务帐户和 google 日历发生了很多变化 我自己在过去几个月中报告了 servral 问题 issue forum 我建议您将此作为问题提交。 Link 在这里,我会看看我是否可以找到我在那个团队的联系人来解决这个问题。
最近有变化
与用户/服务帐户共享日历后,该用户/服务帐户必须通过将共享日历添加到他的日历列表来"accept"共享。
这可以通过单击 "Add this calendar" 从 UI 中完成(如果是用户),也可以使用方法 CalendarList: insert 以编程方式(对用户和服务帐户均有效) .
另一种解决方案是
1) 将日历添加到您的 Google 帐户
2) 与服务帐户电子邮件 ID 共享日历
3) 转到新创建的日历中的设置和共享,然后找到日历 ID
4) 按照这个 Link - https://developers.google.com/calendar/v3/reference/calendarList/insert
这是示例 PHP 用于在服务帐户中添加现有日历的代码
$calendarListEntry = new Google_Service_Calendar_CalendarListEntry();
$calendarListEntry->setId("calendarId");
$createdCalendarListEntry = $service->calendarList->insert($calendarListEntry);
echo $createdCalendarListEntry->getSummary();
5) 现在调用日历列表API,您会在服务帐户日历列表
中找到添加的日历ID