Google Calendar API服务器端访问权限

我实现了一个实用程序,使用Google Calendar API和服务器端身份validation流程执行后台操作,无需用户界面。 现在,我想从私人日历中读取事件,而不使用具有离线访问权限的授权流程或将日历公开。

我正在使用此代码进行身份validation:

GoogleCredential credential = new GoogleCredential.Builder() .setTransport(SchedulerCalendar.HTTP_TRANSPORT) .setJsonFactory(SchedulerCalendar.JSON_FACTORY) .setServiceAccountId(SchedulerCalendar.SERVICE_ACCOUNT_EMAIL) .setServiceAccountScopes(SchedulerCalendar.SCOPES) .setServiceAccountPrivateKeyFromP12File(new File("key.p12")).build(); 

以下是阅读日历事件:

 List eventslist = calendar.events().list(calendarid); 

未找到日历的响应为404。

有什么建议吗?

我解决了将日历共享到*@developer.gserviceaccount.com的问题,并将http://www.google.com/calendar/feeds/添加到了请求的范围内。

我正在使用的日历也来自谷歌应用用户,所以我还添加了我的帐户* .apps.googleusercontent.com – > http://www.google.com/calendar/feeds/来管理来自谷歌的API客户端访问应用控制面板。