是否可以使用服务帐户访问Provisioning API?

2024-02-12

我的服务帐户范围是:https://apps-apis.google.com/a/feeds/user/ https://apps-apis.google.com/a/feeds/user/和 DriveScope.DRIVE

我在我的服务帐户 ID 的域设置中的“管理第三方 OAuth 客户端访问”中授权了相同的范围。

我使用配置 API 的 java 客户端。

我使用 google oauth 客户端构建我的凭据GoogleCredential.Builder :

credBuilder.setTransport(HTTP_TRANSPORT)
        .setJsonFactory(JSON_FACTORY)
        .setServiceAccountId(config.serviceAccountId)
        .setServiceAccountPrivateKeyFromP12File(new File(config.keyFilePath))
        .setServiceAccountScopes(SCOPES);
        .setServiceAccountUser("[email protected] /cdn-cgi/l/email-protection")

我尝试将我的请求授权给配置 api

userService = new UserService(config.repositoryId);
userService.setOAuth2Credentials(oAuthCredentials);

where oAuthCredentials是我之前构建的服务凭证。

通过该配置,我可以访问我域中任何用户的 Google 云端硬盘中的文件和集合。但我无法使用这些凭据访问我的域的用户列表。

如果我不指定服务帐户用户,它也不起作用

这是我得到的堆栈跟踪:

com.google.gdata.util.ServiceForbiddenException: You are not authorized to access this API.
<HTML>
<HEAD>
<TITLE>You are not authorized to access this API.</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
<H1>You are not authorized to access this API.</H1>
<H2>Error 403</H2>
</BODY>
</HTML>
at com.google.gdata.client.http.HttpGDataRequest.handleErrorResponse(HttpGDataRequest.java:605)
at com.google.gdata.client.http.GoogleGDataRequest.handleErrorResponse(GoogleGDataRequest.java:564)
at com.google.gdata.client.http.HttpGDataRequest.checkResponse(HttpGDataRequest.java:560)
at com.google.gdata.client.http.HttpGDataRequest.execute(HttpGDataRequest.java:538)
at com.google.gdata.client.http.GoogleGDataRequest.execute(GoogleGDataRequest.java:536)
at com.google.gdata.client.Service.getFeed(Service.java:1135)
at com.google.gdata.client.Service.getFeed(Service.java:998)
at com.google.gdata.client.GoogleService.getFeed(GoogleService.java:645)
at com.google.gdata.client.Service.getFeed(Service.java:1017)
at com.google.gdata.client.appsforyourdomain.AppsForYourDomainService.getFeed(AppsForYourDomainService.java:137)
at foo.bar.baz.eci.gdrive.service.BaseService$1.doTry(BaseService.java:125)
at foo.bar.baz.eci.gdrive.service.BaseService$1.doTry(BaseService.java:1)
at foo.bar.baz.eci.gdrive.service.backoff.BackoffRequest.execute(BackoffRequest.java:50)
at foo.bar.baz.eci.gdrive.service.BaseService.getFeedWithBackoff(BaseService.java:129)
at foo.bar.baz.eci.gdrive.service.BaseService.retrieveAllEntries(BaseService.java:90)
at foo.bar.baz.eci.gdrive.service.GappsUserService.getAllUserFeed(GappsUserService.java:57)
at foo.bar.baz.eci.gdrive.GdriveContentProviderFactory.doDiscover(GdriveContentProviderFactory.java:67)
... 19 more

以及来自客户端库的日志记录:

21 nov. 2012 15:17:37 com.google.gdata.client.http.HttpGDataRequest setPrivateHeader
PLUS FIN: Authorization: <Not Logged>
21 nov. 2012 15:17:37 com.google.gdata.client.http.HttpGDataRequest setPrivateHeader
PLUS FIN: Authorization: <Not Logged>
21 nov. 2012 15:17:37 com.google.gdata.client.http.HttpGDataRequest setPrivateHeader
PLUS FIN: Authorization: <Not Logged>
21 nov. 2012 15:17:37 com.google.gdata.client.http.HttpGDataRequest setHeader
PLUS FIN: User-Agent: gdocsRepo GData-Java/1.47.1(gzip)
21 nov. 2012 15:17:37 com.google.gdata.client.http.HttpGDataRequest setHeader
PLUS FIN: User-Agent: gdocsRepo GData-Java/1.47.1(gzip)
21 nov. 2012 15:17:37 com.google.gdata.client.http.HttpGDataRequest setHeader
PLUS FIN: User-Agent: gdocsRepo GData-Java/1.47.1(gzip)
21 nov. 2012 15:17:37 com.google.gdata.client.http.HttpGDataRequest setHeader
PLUS FIN: Accept-Encoding: gzip
21 nov. 2012 15:17:37 com.google.gdata.client.http.HttpGDataRequest setHeader
PLUS FIN: Accept-Encoding: gzip
21 nov. 2012 15:17:37 com.google.gdata.client.http.HttpGDataRequest setHeader
PLUS FIN: Accept-Encoding: gzip
21 nov. 2012 15:17:37 com.google.gdata.client.http.HttpGDataRequest setHeader
PLUS FIN: GData-Version: 1.0
21 nov. 2012 15:17:37 com.google.gdata.client.http.HttpGDataRequest setHeader
PLUS FIN: GData-Version: 1.0
21 nov. 2012 15:17:37 com.google.gdata.client.http.HttpGDataRequest setHeader
PLUS FIN: GData-Version: 1.0
21 nov. 2012 15:17:37 com.google.gdata.client.http.HttpGDataRequest execute
FIN: 403 You are not authorized to access this API.
21 nov. 2012 15:17:37 com.google.gdata.client.http.HttpGDataRequest execute
FIN: 403 You are not authorized to access this API.
21 nov. 2012 15:17:37 com.google.gdata.client.http.HttpGDataRequest execute
FIN: 403 You are not authorized to access this API.
21 nov. 2012 15:17:37 com.google.gdata.client.http.HttpGDataRequest execute
PLUS FIN: Content-Encoding: gzip
21 nov. 2012 15:17:37 com.google.gdata.client.http.HttpGDataRequest execute
PLUS FIN: Content-Encoding: gzip
21 nov. 2012 15:17:37 com.google.gdata.client.http.HttpGDataRequest execute
PLUS FIN: Content-Encoding: gzip
21 nov. 2012 15:17:37 com.google.gdata.client.http.HttpGDataRequest execute
PLUS FIN: Content-Length: 151
21 nov. 2012 15:17:37 com.google.gdata.client.http.HttpGDataRequest execute
PLUS FIN: Content-Length: 151
21 nov. 2012 15:17:37 com.google.gdata.client.http.HttpGDataRequest execute
PLUS FIN: Content-Length: 151
21 nov. 2012 15:17:37 com.google.gdata.client.http.HttpGDataRequest execute
PLUS FIN: null: HTTP/1.1 403 You are not authorized to access this API.
21 nov. 2012 15:17:37 com.google.gdata.client.http.HttpGDataRequest execute
PLUS FIN: null: HTTP/1.1 403 You are not authorized to access this API.
21 nov. 2012 15:17:37 com.google.gdata.client.http.HttpGDataRequest execute
PLUS FIN: null: HTTP/1.1 403 You are not authorized to access this API.
21 nov. 2012 15:17:37 com.google.gdata.client.http.HttpGDataRequest execute
PLUS FIN: Expires: Wed, 21 Nov 2012 14:17:37 GMT
21 nov. 2012 15:17:37 com.google.gdata.client.http.HttpGDataRequest execute
PLUS FIN: Expires: Wed, 21 Nov 2012 14:17:37 GMT
21 nov. 2012 15:17:37 com.google.gdata.client.http.HttpGDataRequest execute
PLUS FIN: Expires: Wed, 21 Nov 2012 14:17:37 GMT
21 nov. 2012 15:17:37 com.google.gdata.client.http.HttpGDataRequest execute
PLUS FIN: X-XSS-Protection: 1; mode=block
21 nov. 2012 15:17:37 com.google.gdata.client.http.HttpGDataRequest execute
PLUS FIN: X-XSS-Protection: 1; mode=block
21 nov. 2012 15:17:37 com.google.gdata.client.http.HttpGDataRequest execute
PLUS FIN: X-XSS-Protection: 1; mode=block
21 nov. 2012 15:17:37 com.google.gdata.client.http.HttpGDataRequest execute
PLUS FIN: X-Frame-Options: SAMEORIGIN
21 nov. 2012 15:17:37 com.google.gdata.client.http.HttpGDataRequest execute
PLUS FIN: X-Frame-Options: SAMEORIGIN
21 nov. 2012 15:17:37 com.google.gdata.client.http.HttpGDataRequest execute
PLUS FIN: X-Frame-Options: SAMEORIGIN
21 nov. 2012 15:17:37 com.google.gdata.client.http.HttpGDataRequest execute
PLUS FIN: Date: Wed, 21 Nov 2012 14:17:37 GMT
21 nov. 2012 15:17:37 com.google.gdata.client.http.HttpGDataRequest execute
PLUS FIN: Date: Wed, 21 Nov 2012 14:17:37 GMT
21 nov. 2012 15:17:37 com.google.gdata.client.http.HttpGDataRequest execute
PLUS FIN: Date: Wed, 21 Nov 2012 14:17:37 GMT
21 nov. 2012 15:17:37 com.google.gdata.client.http.HttpGDataRequest execute
PLUS FIN: Content-Type: text/html; charset=UTF-8
21 nov. 2012 15:17:37 com.google.gdata.client.http.HttpGDataRequest execute
PLUS FIN: Content-Type: text/html; charset=UTF-8
21 nov. 2012 15:17:37 com.google.gdata.client.http.HttpGDataRequest execute
PLUS FIN: Content-Type: text/html; charset=UTF-8
21 nov. 2012 15:17:37 com.google.gdata.client.http.HttpGDataRequest execute
PLUS FIN: Server: GSE
21 nov. 2012 15:17:37 com.google.gdata.client.http.HttpGDataRequest execute
PLUS FIN: Server: GSE
21 nov. 2012 15:17:37 com.google.gdata.client.http.HttpGDataRequest execute
PLUS FIN: Server: GSE
21 nov. 2012 15:17:37 com.google.gdata.client.http.HttpGDataRequest execute
PLUS FIN: X-Content-Type-Options: nosniff
21 nov. 2012 15:17:37 com.google.gdata.client.http.HttpGDataRequest execute
PLUS FIN: X-Content-Type-Options: nosniff
21 nov. 2012 15:17:37 com.google.gdata.client.http.HttpGDataRequest execute
PLUS FIN: X-Content-Type-Options: nosniff
21 nov. 2012 15:17:37 com.google.gdata.client.http.HttpGDataRequest execute
PLUS FIN: Cache-Control: private, max-age=0
21 nov. 2012 15:17:37 com.google.gdata.client.http.HttpGDataRequest execute
PLUS FIN: Cache-Control: private, max-age=0
21 nov. 2012 15:17:37 com.google.gdata.client.http.HttpGDataRequest execute
PLUS FIN: Cache-Control: private, max-age=0

经过调查,如果设置的帐户似乎会出现 403 错误.setServiceAccountUser("[email protected] /cdn-cgi/l/email-protection")不是域的“超级管理员”。

然而在上述情况下“[电子邮件受保护] /cdn-cgi/l/email-protection“确实是域的超级管理员。此外,该代码与域的任何其他超级管理员都能很好地配合,这导致人们相信该帐户有问题”[电子邮件受保护] /cdn-cgi/l/email-protection“ 尤其。

如果这种情况发生在其他人身上 - 也就是设置为“超级管理员”的帐户无法通过服务帐户访问仅限管理员使用的 API - 请务必在下面的评论中告知我们,我们将进一步调查这是否影响很大的人。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

是否可以使用服务帐户访问Provisioning API? 的相关文章

随机推荐

  • 将字符串与枚举进行比较

    我正在使用名为 FindBugs 的静态分析工具分析以下代码 if str equals enum SOMEVALUE do something 其中 str 是字符串 enum 是枚举 该工具会为此代码生成以下警告 并指出 此方法对没有公
  • 需要布尔转换器 Struts2 来表示是、否、空白值

    我需要根据 UI 表单元素上选择的值保存数据
  • Django 管理:类媒体

    我有一个媒体类如下 class helloAdmin admin ModelAdmin class Media js choice js admin site register hello helloAdmin staticfiles 应用
  • 为什么 scanf("%d", [...]) 不消耗 '\n'?而 scanf("%c") 呢?

    Here https stackoverflow com questions 217074 parsing input with scanf in c 我在接受的答案中看到了这样的说法 大多数转换说明符会跳过前导空格 包括换行符 但是 c才
  • 使用 jQuery 切换类

    当用户单击链接时 我需要隐藏 div html 是这样的 div class item div class entry Lorem ipsum div a href class commentsToggle Show hide commen
  • Ionic - 如何设置 高度,以便它在所有分辨率设备中自动调整?

    我的代码如下
  • 如何在关闭时完全删除对话框

    当 ajax 操作失败时 我创建一个包含错误的新 div 然后将其显示为对话框 当对话框关闭时 我想完全销毁并再次删除 div 我怎样才能做到这一点 我的代码目前看起来像这样 div We failed div dialog title E
  • 在Java中查找数组中的元素

    Java 是否有内置函数允许我线性搜索数组中的元素 还是必须只使用 for 循环 有一个contains列表的方法 所以你应该能够这样做 Arrays asList yourArray contains yourObject 警告 这可能不
  • Flutter - 英雄动画不适用于选项卡导航器

    我是颤振新手 我正在使用英雄小部件为浮动按钮制作动画 我有底部导航 我必须使用选项卡导航器打开页面 但英雄动画不起作用 我使用了所有可能的解决方案 但英雄动画仍然不适用于页面路由 这是我的代码片段 FloatingActionButton
  • 无法删除全局包

    尝试删除全局包 但似乎没有删除它 eslint v v1 10 3 npm uninstall eslint g sudo npm uninstall eslint g eslint v v1 10 3 sudo eslint v v1 1
  • 如何使用之前输入的值填充自定义结帐字段,例如默认的 WooCommerce 结帐字段?

    我使用以下代码添加了一个自定义字段 add action woocommerce before order notes bbloomer add custom checkout field function bbloomer add cus
  • 在python中读取15M行csv文件的有效方法

    对于我的应用程序 我需要读取多个文件 每个文件有 15 M 行 将它们存储在 DataFrame 中 并将 DataFrame 保存为 HDFS5 格式 我已经尝试过不同的方法 特别是具有 chunksize 和 dtype 规范的 pan
  • 获取调用者类

    我正在编写 Logger 并在自动添加类名时遇到问题 我从中调用了 print log 方法 例如这样的事情 class Logger def self print log string puts Time now strftime T c
  • 美国电话号码验证

    我有一个网站表单 需要输入美国电话号码以供后续使用 在这种情况下这是非常有必要的 我想尝试消除用户输入垃圾数据330 000 0000 我已经看到了第三方为您验证电话号码的一些选项 但是我不知道这是否是这种情况的最佳选择 但是 如果您使用过
  • PyQt 项目视图自定义拖放

    我正在 QTableView 中进行自定义拖放实现 当我拖动一个单元格并将其放在另一个单元格上时 我想根据拖动的内容和放置的位置手动更改模型中的一些数据 我怎样才能做到这一点 我已经阅读了所有 Qt 文档 但我完全迷失了 特别是通过拖放 C
  • Couchbase 中的存储桶密码

    我正在创建一个使用 springboot 和 Couchbase 进行反应式编程的演示项目 我在 application properties 文件中设置了以下属性 spring couchbase bootstrap hosts loca
  • APK 0(零)设备兼容性

    我正在生成一个要在商店上发布的 APK 它是现有应用程序的更新 上传到 Google Play Console 后 支持的 Android 设备 0 台设备 这是我的清单
  • vue js如何使用方法将数据从父组件、v-for循环列表传递到子组件

    我试图实现在子组件 模态组件 中显示每个项目收据数组的项目列表 但一直无法这样做 方法display receipts 是将receipts modal的数据值改为true 我可以在哪里放置 v bind 来传递数组 任何帮助深表感谢 Pa
  • 使用networkx从图中删除边

    我正在尝试转换DiGraph成n叉树并按层序或BFS显示节点 我的树与此类似 但更大 为简单起见 使用以下示例 G networkx DiGraph G add edges from n n1 n n2 n n3 G add edges f
  • 是否可以使用服务帐户访问Provisioning API?

    我的服务帐户范围是 https apps apis google com a feeds user https apps apis google com a feeds user 和 DriveScope DRIVE 我在我的服务帐户 ID