java - 在同一个应用程序中使用两个 Google API

标签 java google-drive-api google-directory-api

我有一个连接到 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 开发者控制台

左侧菜单单击“凭据”,然后顶部的按钮显示“创建凭据”

enter image description here

创建后,单击箭头下载,您可以随时下载该文件

enter image description here

关于java - 在同一个应用程序中使用两个 Google API,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60855015/

相关文章:

java - 有条件的进口

php - Google Drive API V3、PHP 客户端、转移文件所有权

java - 如何使用 Java 更新用户的 externalId

google-admin-sdk - 目录 API,用户组织 - 名称字段。它从何而来?

python - Google Admin SDK 错误资源未找到 : domain when trying to list existing users

java - NTLM 身份验证方案选择错误

java - 如果出现任何类型的异常,重定向到错误 Controller ?

java - 为什么我的水平回收 View 不会在 fragment 中滚动

javascript - 为什么我的 Google Picker 窗口不会出现在浏览器中

google-apps-script - 使用 Google Apps 脚本获取 Google Drive 事件