我有一个这样构建的日历客户端
insert_question()
public static Calendar getCalendar(Credential credentials) throws GeneralSecurityException, IOException {
return new Calendar.Builder(GoogleNetHttpTransport.newTrustedTransport(), JSON_FACTORY, credentials)
.setApplicationName(APPLICATION_NAME)
.build();
}
有效并返回结果
但是这个人抱怨401:未经授权
calendar.events().list("primary").execute()
我请求了 public static String subscirbeToHook(Credential user, Calendar service) throws IOException {
Channel content = new Channel()
.setId(UUID.randomUUID().toString())
.setType("web_hook")
.setResourceUri("https://www.googleapis.com/calendar/v3/calendars/primary/events/watch")
.setAddress("https://2e8e18e3.ngrok.io/");
Channel channel = service.events()
.watch("primary", content)
.execute();
return channel.getResourceId();
}
范围。我迷路了。我为资源uri尝试了不同的组合
答案 0 :(得分:0)
似乎resourceURI
不能进行更改,因为Calendar Push Notifications当前不受支持。
当前,Google Calendar API支持更改通知 访问“ Acl”,“ CalendarList”,“事件”和“设置”资源。
以下是受支持的Events resources请求正文:
{
"id": string,
"token": string,
"type": string,
"address": string,
"params": {
"ttl": string
}
}
如果成功,此方法将返回具有以下结构的响应主体:
{
"kind": "api#channel",
"id": string,
"resourceId": string,
"resourceUri": string,
"token": string,
"expiration": long
}