javagooglecalendarapi:com。谷歌。应用程序编程接口。客户古格里皮斯。json。谷歌JSONResponseException
We are trying to access the users calendar for Google workspace users(formally G Suite) using google calendar API via Google cloud platform (GCP)
We followed the following setup.
1) Set up domain-wide delegation for a client Ref link (https://support.google.com/a/answer/162106?hl=en)
2) We have created a service account with an email id and got the client id as per the article above article.
3) We have then assigned Calendar API to created client id with read-only permission with below scopes
a> https://www.googleapis.com/auth/calendar.readonly
b> https://www.googleapis.com/auth/calendar.events.readonly
c> https://www.googleapis.com/auth/calendar.settings.readonly
4) Now at this point we are unable to see others users calendars except own and get the above error.
5) Also, when I tried accessing the Calendar events listing using the Google Api portal (https://developers.google.com/calendar/v3/reference/events/list?apix_params=%7B%22calendarId%22%3A%22bizzhub%40embibe.com%22%7D), I was able to authorize and see the events.
I tried accessing the events I created on the calendar using the google apis. But, I keep getting the below error.
com.google.api.client.googleapis.json.GoogleJsonResponseException: 404 Not Found
{
"code" : 404,
"errors" : [ {
"domain" : "global", "message" : "Not Found", "reason" : "notFound"
} ],
"message" : "Not Found"
}
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:1049)
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 GoogleCalendarUtil2.getEventsList(GoogleCalendarUtil2.java:49)
at GoogleCalendarMain.call(GoogleCalendarMain.java:13)
at GoogleCalendarMain.main(GoogleCalendarMain.java:7)
下面是代码
{
"type": "service_account",
"project_id": "smartworkspace2020",
"private_key_id": "d6c2122d26ab25f908cf66d06a5ead1f77d7f013",
"private_key": "-----BEGIN PRIVATE KEY-----
-----END PRIVATE KEY-----\n",
"client_email": "bizzhub-2020-219@smartworkspace2020.iam.gserviceaccount.com",
"client_id": "117169030512379080380",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/bizzhub-2020-219%40smartworkspace2020.iam.gserviceaccount.com"
}
共 (0) 个答案