Google Calendar: freeBusy giving error “notFound”

2019-08-29 09:18发布

To start off I'm using a google apps for business account and I have 2 accounts test1@mycompany.com and test2@mycompany.com

After that I have an Api E-Mail that is registered in the API console to test1@mycompany.com which I'll represent as #####@developer.gserviceaccount.com

The query is a simple, I simply have a timeMin & timeMax & 2 items each with id's i send this using the Java client API

First query with GoogleAuthorizationCodeFlow and using test1@mycompany.com

{
 "kind": "calendar#freeBusy",
 "timeMin": "2013-03-26T22:50:16.501Z",
 "timeMax": "2013-03-26T22:50:22.501Z",
 "calendars": {
  "test1@mycompany.com": {
   "busy": []
  },
  "test2@mycompany.com": {
   "busy": []
  }
 }
}

This is what I get for the second authorization method using (Getting the error "notFound")

GoogleCredential.Builder()
.setServiceAccountId("#####@developer.gserviceaccount.com")
.setServiceAccountPrivateKeyFromP12File("key.p12").etc().etc()

{
 "kind": "calendar#freeBusy",
 "timeMin": "2013-03-26T22:19:14.770Z",
 "timeMax": "2013-03-26T22:19:20.770Z",
 "calendars": {
  "test1@mycompany.com": {
   "busy": []
  },
  "test2@mycompany.com": {
   "errors": [
    {
     "domain": "global",
     "reason": "notFound"
    }
   ],
   "busy": []
  }
 }
}

Even though test1@mycompany.com can gain access to test2@mycompany.com #####@developer.gserviceaccount.com cannot, why is this they are both really the same account are they not? #####@developer.gserviceaccount.com belongs to test1@mycompany.com anyways. Test2@mycompany.com is set to share the calendar(As evident in the first query) and I don't know why the developer account doesn't have access to that business.

2条回答
霸刀☆藐视天下
2楼-- · 2019-08-29 09:40

I expected a similar result as you, but I also got a notFound error when using the service_account credentials. The solution that worked for me was to go into the calendar sharing page and explicitly share my calendar with the #####@developer.gserviceaccount.com email address.

查看更多
在下西门庆
3楼-- · 2019-08-29 09:42

I apologize for not having more specifics, but how this was eventually resolved was by having the owner of the Apps for Business account add the developer email address ( #####@developer.gserviceaccount.com) as a delegate, and now I can get freeBusy times of anyone on the business account. The other answer of adding the #####@developer.gserviceaccount.com as a user on the calendar itself also worked.(Though I would have had to do this for every user)

查看更多
登录 后发表回答