使用服务帐户获取/添加事件到谷歌日历 [英] GET/ADD Events to google calendar with a service account

查看:172
本文介绍了使用服务帐户获取/添加事件到谷歌日历的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须从java web应用程序访问Google日历以获取并特别将事件添加到共享的Google日历中
我遵循java快速入门



如果您希望通过 calendar.list 致电从服务帐户代码 Calendarlist.insert 。您只需运行一次即可将相关日历插入到服务帐户日历列表中。



尝试运行 Calendars.get 应该有权访问日历,而无需将其插入calendar.list


I have to access a google calendar from a java webapplication to get and especially add events to a shared google calendar I followed the java quickstart example from google and everything works fine so far

then I changed the authorize method in that example to use a service account and the authentication seems to work but the calendar List returned from google is empty

I already shared the calendar with the service account email but that doesnt change anything

解决方案

Service account is a dummy user. It has its own Google Calendar account. By default it doesn't have access to any Google Calendars you need to either share a google calendar with it or insert a new Google Calendars into it.

Calendar.list is something else entirely its basically the little box at the bottom left in the Calendars website. In order for a calendar to appear there it I needs to be inserted into the calendar.list.

Solution:

Go to the Google calendar website add the service account email address as a user of your calendar. Then the service account will be able to access it. If you want you can programmatically insert it into calendar.list if you really need it to be there. IMO there is really not much point for Calendar.list with a service account.

update

You should be able to grant your service account access to do what ever you like like any other user.

If you want it in calendar.list call Calendarlist.insert from the service account code. You will only need to run it once to insert the calendar in question into the service accounts calendar list.

try running Calendars.get on the calendar it should have access without needing to insert it into calendar.list

这篇关于使用服务帐户获取/添加事件到谷歌日历的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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