【问题标题】:Google Directory API returns not authorized for users().patch().execute()Google Directory API 返回未经授权的 users().patch().execute()
【发布时间】:2017-03-06 14:20:46
【问题描述】:

我正在关注 https://aws.amazon.com/blogs/security/how-to-set-up-federated-single-sign-on-to-aws-using-google-apps/ 并尝试设置一个脚本来为我的 Google 用户修补 SSO AWS 角色。

使用https://developers.google.com/admin-sdk/directory/v1/reference/users/patch 列出的范围,我已经正确验证并通过简单的操作确认:

service.users().list(customer='my_customer', maxResults=10, orderBy='email').execute()

这会成功返回一个用户列表。但是,当我尝试使用以下命令执行补丁查询时:

service.users().patch(body=body, userKey=user_email).execute()

响应是“未授权访问此资源/api”。

这个端点在某些方面是特殊的吗?看来成功访问此资源的唯一方法是使用超级管理员帐户进行身份验证,我不希望这样做。

【问题讨论】:

    标签: google-api google-admin-sdk google-api-python-client


    【解决方案1】:

    请注意,Directory API: Authorize Requests 中提到过,

    您的应用程序必须使用 OAuth 2.0 来授权请求​​。不支持其他授权协议。如果您的应用程序使用 Google 登录,则会为您处理授权的某些方面。

    有了这个,我建议你使用Authorizing requests with OAuth 2.0

    您还可以从这些 SO 帖子中检查为什么会遇到此类错误的其他可能性:

    希望有帮助!

    【讨论】:

      猜你喜欢
      • 2013-09-05
      • 1970-01-01
      • 2014-10-22
      • 2016-12-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多