在不使用G-Suite的情况下为服务帐户授权Google日历 [英] Authorizing Google Calendar for Service Account WITHOUT G-Suite

查看:76
本文介绍了在不使用G-Suite的情况下为服务帐户授权Google日历的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将Google Calendar API与服务帐户一起使用来检索事件.但是,列出日历或事件不会返回任何内容(不是错误,仅返回0条记录).有很多使用G-Suite进行域范围授权的文档/示例,但这只是一个Google单独帐户-它不属于任何G-Suite域.

I'm trying to use the Google Calendar API with a Service Account to retrieve events. However, listing calendars or events returns nothing (not an error, just 0 records returned). There's lots of documentation/examples for domain-wide authorization using G-Suite, but this just an individual Google account -- it is not part of any G-Suite domain.

我确实在共享下的日历中添加了服务帐户的电子邮件地址,但是当我尝试检索数据时日历仍然不显示.

I did add the email address of the service account to the calendar under sharing, but the calendar still doesn't show when I try to retrieve data.

我应该使用某个URL吗?还是我缺少Google控制台中的某种配置设置?

Is there a certain URL I should be using? Or is there some kind of configuration setting in Google Console I'm missing?

推荐答案

添加服务帐户的电子邮件地址不足以共享日历:该帐户还必须accept日历.看起来这是由于最近的行为变化所致.

Adding the Service Account's email address is not enough to share the Calendar: the account also has to accept the Calendar. Looks like this is because of a recent change of behaviour.

来自以下问题跟踪器中的评论:

From this comment in Issue Tracker:

由于最近的行为改变,任何帐户都必须明确地接受"交易.与他们共享的日历.如果是服务帐户,则此接受"是指应该通过 CalendarList.insert 将日历添加到CalendarList中来完成 a>.

Due to a recent change of behaviour, any account has to explicitly "accept" a Calendar that has been shared with them. In case of a Service Account, this "acceptance" should be made by adding the calendar to the CalendarList via CalendarList.insert.

也就是说,添加服务帐户地址后,您必须致电 CalendarList.insert 将此日历添加到服务帐户的日历列表中.在通话中,您只需要在请求正文中提供相应的日历id.

That is to say, after adding the Service Account address, you have to call CalendarList.insert to add this Calendar to the Service Account's calendar list. In your call, you just have to provide the corresponding Calendar id in the request body.

这篇关于在不使用G-Suite的情况下为服务帐户授权Google日历的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆