首先,我使用 google 应用程序作为企业帐户,我有 2 个帐户 test1@mycompany.com 和 test2@mycompany.com
之后,我有一个在 API 控制台中注册到 test1@mycompany.com 的 Api 电子邮件,我将其表示为 #####@developer.gserviceaccount.com
查询很简单,我只有一个 timeMin & timeMax & 2 个项目,每个项目都有 id 我使用 Java 客户端 API 发送这个
使用 GoogleAuthorizationCodeFlow 并使用 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": []
}
}
}
这是我使用第二种授权方法得到的(获取错误“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": []
}
}
}
即使 test1@mycompany.com 可以访问 test2@mycompany.com #####@developer.gserviceaccount.com 不能,为什么这两个帐户实际上是同一个帐户,不是吗?#####@developer.gserviceaccount.com 无论如何都属于 test1@mycompany.com。Test2@mycompany.com 设置为共享日历(在第一个查询中很明显),我不知道为什么开发人员帐户无权访问该业务。