Google Directory API未授权用户返回()。patch()。execute()

时间:2016-10-24 18:00:37

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

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

使用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"。

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

1 个答案:

答案 0 :(得分:0)

请注意,Directory API: Authorize Requests中提及了

  

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

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

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

希望有所帮助!

相关问题