google日历api:com.google.api.client.googleapis.json.googlejsonresponseexception

pn9klfpd  于 2021-07-06  发布在  Java
关注(0)|答案(0)|浏览(265)
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
{
“代码”:404,
“错误”:[{

"domain" : "global",

"message" : "Not Found",

"reason" : "notFound"

} ],
“message”:“找不到”
}
在com.google.api.client.googleapis.json.googlejsonresponseexception.from(googlejsonresponseexception。java:146)
在com.google.api.client.googleapis.services.json.abstractgooglejsonclientrequest.NewExceptionError(abstractgooglejsonclientrequest。java:113)
在com.google.api.client.googleapis.services.json.abstractgooglejsonclientrequest.NewExceptionError(abstractgooglejsonclientrequest。java:40)
在com.google.api.client.googleapis.services.abstractgoogleclientrequest$1.interceptresponse(abstractgoogleclientrequest)。java:321)
在com.google.api.client.http.httprequest.execute(httprequest。java:1049)
在com.google.api.client.googleapis.services.abstractgoogleclientrequest.executeunparsed(abstractgoogleclientrequest。java:419)
在com.google.api.client.googleapis.services.abstractgoogleclientrequest.executeunparsed(abstractgoogleclientrequest。java:352)
在com.google.api.client.googleapis.services.abstractgoogleclientrequest.execute(abstractgoogleclientrequest。java:469)
在googlecalendarutil2.geteventslist(googlecalendarutil2。java:49)
在googlecalendarmain.call(googlecalendarmain。java:13)
在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"
}

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题