Shared as usual to service account, calendar does not appear in the list when querying it from Calendar API

huangapple go评论78阅读模式
英文:

Shared as usual to service account, calendar does not appear in the list when querying it from Calendar API

问题

我有大约51个Google日历共享给一个Google服务帐号,它们仍然正常运行,我定期收到它们的推送通知。我以通常的方式添加了一个更多的日历:“分享给其他人”,并将电子邮件设置为我的服务帐号。然后我尝试获取所有与服务帐号连接的日历列表,但无法获取最新的那个。它不见了。

以下是我过去2-3年来使用的Joomla PHP代码:

public function loadCalendarList() {
    
    $this->user = JFactory::getUser();
    if ($this->_connect()) {
        $list = $this->_service->calendarList->listCalendarList();
        if (!empty($list['items'])) {
        ....

除了新的那个之外,所有日历都被加载。
我在互联网上搜索了很多,但没有线索,
我没有使用G Suite。
如果我使用Google OAuth 2.0授权而没有任何服务帐号,我可以加载所有52个日历,包括新的一个。
再想一想:我已经好几个月没有添加到这个新的日历了,我认为Google发生了一些变化?

英文:

I have around 51 Google calendars shared to a google service account and they are still working well, I am getting push notification from them on a regular basis. I added one more calendar in the usual way with: "share to other people" and set e-mail to my service account. I then tried to get a list of all calendars that are connected to the service account I can not get the newest one. It is absent.

Here is the Joomla php code I have used for the past 2-3 years:

public function loadCalendarList() {
    
    $this->user = JFactory::getUser();
    if ($this->_connect()) {
        **$list = $this->_service->calendarList->listCalendarList();**
        if (!empty($list['items'])) {
....

All calendars except new one are loaded.
I have search all over internet but no clue,
I am not using G Suite.
If I use google OAuth 2.0 authorisation without any service account I can load all 52 calendar with the new one.
One more thought: I have not added to this new calendar for several months, I think something changed in google?

答案1

得分: 0

对于新共享的日历,在与服务帐户共享日历后,您需要明确将其插入到服务帐户的日历列表中。类似这样:

$newCalendar = new Google_Service_Calendar_CalendarListEntry();
$newCalendar->setId("新添加的日历的ID");
$service->calendarList->insert($newCalendar);
英文:

For newly shared calendars, after sharing a calendar with the service account, you need to explicitly insert it into the service account's calendar list. Something like this:

$newCalendar=new Google_Service_Calendar_CalendarListEntry();
$newCalendar->setId("THE ID OF THE NEWLY ADDED CALENDAR");
$service->calendarList->insert($newCalendar);

huangapple
  • 本文由 发表于 2020年1月3日 23:00:18
  • 转载请务必保留本文链接:https://go.coder-hub.com/59580784.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定