当通过OAuth 2.0使用服务帐户调用v3 Google日历API时,出现403禁止消息 [英] 403 Forbidden message when calling the v3 Google Calendar API using a Service Account via OAuth 2.0
问题描述
这是我的主题关于使用Google Calendar API和OAuth2时出现401错误的后续操作,可以在 这是返回的错误消息: 我尝试了什么?好吧,我已经重新阅读了(相当差劲的)关于服务帐户的Google文档,重新检查了我的API控制台帐户设置,尝试更改了构建证书的代码(这会导致其他错误,因此是我先前线程的回归) 简而言之,什么都没有,所以我有什么明显的遗漏吗? 已解决,这要感谢此帖子.>
您必须将Google日历帐户中的日历与在Google API控制台中生成的服务帐户电子邮件共享,例如 284XXXXXXXX@developer.gserviceaccount.com . 我现在可以从Web服务更新日历. This is a follow on from my thread about a 401 error when using the Google Calendar API and OAuth2, which can be found here This contains details of the account setup that leads onto my next question, so I wont repeat myself in this thread. OK, so when when I call the following code to update a Calendar event I get a 403 forbidden error. Here is the returned error message: What have I tried? Well, I have re-read the (rather poor) Google documentation about Service Accounts, re-checked my API Console account settings, tried changing the code that builds the credential (this leads to other errors so is a regression on my previous thread). In short, nothing works, so is there anything obvious I am missing? Solved, thanks to this post. You have to share the calendar from your Google Calendar account with the Service Account email that is generated in the Google API Console, e.g. 284XXXXXXXX@developer.gserviceaccount.com. I can now update my calendar from my web service. 这篇关于当通过OAuth 2.0使用服务帐户调用v3 Google日历API时,出现403禁止消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!com.google.api.client.googleapis.json.GoogleJsonResponseException: 403 Forbidden
{
"code" : 403,
"errors" : [ {
"message" : "Forbidden"
} ],
"message" : "Forbidden"
}
for (Event event : events.getItems())
{
event.setSummary("XXX" + event.getSummary());
Event updatedEvent = calendar.events().update(CALENDAR_ID, event.getId(), event).execute();
}
com.google.api.client.googleapis.json.GoogleJsonResponseException: 403 Forbidden
{
"code" : 403,
"errors" : [ {
"message" : "Forbidden"
} ],
"message" : "Forbidden"
}