【发布时间】:2019-04-09 21:11:56
【问题描述】:
我有一个这样构建的日历客户端
public static Calendar getCalendar(Credential credentials) throws GeneralSecurityException, IOException {
return new Calendar.Builder(GoogleNetHttpTransport.newTrustedTransport(), JSON_FACTORY, credentials)
.setApplicationName(APPLICATION_NAME)
.build();
}
calendar.events().list("primary").execute() 工作并返回结果
但是这个抱怨401:未授权
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();
}
我请求https://www.googleapis.com/auth/calendar 范围。我迷路了。我为资源 uri 尝试了不同的组合
【问题讨论】:
标签: google-calendar-api google-api-java-client