授权谷歌日历api适用于个人帐户但不适用于谷歌域帐户 [英] authorize google calendar api works on personal account but not on google domain account
问题描述
我需要制作一个 Java 应用程序,用于在 Google 域内的员工中存储日历事件.我根据在 http 上找到的示例创建了该应用程序://code.google.com/p/google-api-java-client/wiki/APIs#Calendar_API
I need to make a Java application that stores calendar events in employees within a Google Domain. I created the application based on a sample I found on http://code.google.com/p/google-api-java-client/wiki/APIs#Calendar_API
现在我想让它在来自 google 域的帐户上工作,但突然我被卡住了.我用一个新文件更改了 client_secrets.json 文件.在 code.google.com/apis/console 上为已安装的应用程序生成了一个无效的客户端错误:
Now I wanted to make it work on an account from the google domain and suddenly I'm stuck. I changed the client_secrets.json file with a new one. generated on code.google.com/apis/console for an installed application and now I get a invalid client error:
ex = (com.google.api.client.auth.oauth2.TokenResponseException) com.google.api.client.auth.oauth2.TokenResponseException: 400 错误请求{错误":unauthorized_client"}
ex = (com.google.api.client.auth.oauth2.TokenResponseException) com.google.api.client.auth.oauth2.TokenResponseException: 400 Bad Request { "error" : "unauthorized_client" }
我是否需要为此执行其他步骤?此外,默认情况下,它需要在域内的所有帐户上工作,而不是在单个帐户上工作.也许其他控制台?我希望不是其他图书馆.
Do I need to do other steps for this? Also it needs to work on all accounts by default within the domain not the single account. Maybe other console? I hope not an other library.
推荐答案
要访问域中的所有帐户,您需要使用服务帐户:
To have access to all accounts in the domain, you need to use a service account:
https://developers.google.com/accounts/docs/OAuth2ServiceAccount
虽然此链接特定于 Drive API,但它应该会为您提供一些易于适应 Calendar API v3 的代码示例:
while this link is specific to Drive API, it should give you some code samples that are easily adaptable to Calendar API v3:
https://developers.google.com/drive/delegation
这篇关于授权谷歌日历api适用于个人帐户但不适用于谷歌域帐户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!