我使用Google oauth playground.I获取访问令牌并尝试使用Java代码创建事件,但是我可以创建一些电子邮件ID,但是对于其他电子邮件ID,它会给出:
com.google.api.client.googleapis.json.GoogleJsonResponseException: 401 Unauthorized
at com.google.api.client.googleapis.json.GoogleJsonResponseException.from(GoogleJsonResponseException.java:146)
at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:113)
at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:40)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest$1.interceptResponse(AbstractGoogleClientRequest.java:321)
at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:1065)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:419)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:352)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:469)
at com.techjini.university.utils.GoogleUtils.createUpdateEvent(GoogleUtils.java:160)
此代码行中的此异常
event = getCalendarService(accessToken).events().insert("primary", event).execute();
System.out.printf("Event created: %s\n", event.getId());
createList.add(event.getId());
我无法获取calendarId请告知我们在日历中设置的这个或任何权限有什么问题,但有些电子邮件ID我可以创建活动。