我有一个连接到 Google Drive API 的应用程序。 现在我必须添加另一个需要 Google Directory API 的功能。 我授予了必要的权限并在我的项目中启用了新的 API。
但是我仍然收到此错误:
"message" : "Access Not Configured. Admin Directory API has not been used in project 594418282793 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/admin.googleapis.com/overview?project=594418282793 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry."
问题是消息中的 URL 给了我一个错误;显然项目 ID 无效。 这是错误:
There was an error while loading /apis/dashboard?project=594418282793. You are missing at least one of the following required permissions:
Project
resourcemanager.projects.get
Check that the project ID is valid and you have permissions to access it.
我不知道造成这种不匹配的原因是什么,为什么错误消息中提供的项目 ID 似乎不存在,以及我还应该在应用程序中的何处启用第二个 API。 任何想法将不胜感激。
最佳答案
我认为您没有理解credentials.json 的工作原理。
Access Not Configured.
表示您为此客户端加载的凭据尚未针对您尝试连接的 API 设置。
当您在 Google 开发者控制台上创建项目时,这是为了向 Google 提供有关您的应用程序的整体信息及其设计用途的信息。您应该在单个项目中启用这两个 API。
完成后,创建您的 Oauth 凭据,就像您之前所做的那样,此凭据文件将能够连接到两个 api。
googel 开发者控制台
左侧菜单单击“凭据”,然后顶部的按钮显示“创建凭据”
创建后,单击箭头下载,您可以随时下载该文件
关于java - 在同一个应用程序中使用两个 Google API,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60855015/