Google范围列出域中的用户?
我一直在使用 users.list 方法 获取域中所有用户的列表。文档说,我们需要以下范围中的一个:
- https: //www.googleapis.com/auth/admin.directory.user
- https://www.googleapis.com/auth/admin.directory.user.readonly
- https://www.googleapis.com/auth/cloud-platform
尝试 &错误我发现(至少对我来说)它只适用于这些(全部!):
- https://www.googleapis.com/auth/admin.directory.domain
- https://www.googleapis.com/auth/admin.directory.user
我错过了什么吗?或者我处于错误的环境中?
I've been using the users.list method to get a list of all users in a domain. The docs say, we need one of theses scopes:
- https://www.googleapis.com/auth/admin.directory.user
- https://www.googleapis.com/auth/admin.directory.user.readonly
- https://www.googleapis.com/auth/cloud-platform
With try & error I found that (at least for me) it is only working with these (all!):
- https://www.googleapis.com/auth/admin.directory.domain
- https://www.googleapis.com/auth/admin.directory.user
Do I have missed something? Or am I in the wrong context?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
https://www.googleapis.com/auth/admin.directory.domain
可能已被代码中的其他内容使用。 User.list 只需要https://www.googleapis.com/auth/admin.directory.user
我认为可能的罪魁祸首是您的授权代码。如果您选中Directory API:授权请求,您就会看到它说
这可能意味着为了授权用户,您需要该范围。这与列表方法使用的
https://www.googleapis.com/auth/admin.directory.user
范围无关。https://www.googleapis.com/auth/admin.directory.domain
is probably used by something else in your code. User.list only needshttps://www.googleapis.com/auth/admin.directory.user
Imo the likely culprit would be your authorization code. If you check Directory API: Authorize Requests you will see it says
Which may mean that in order to authorize a user you need that scope. Which would be unrelated to the
https://www.googleapis.com/auth/admin.directory.user
scope used for the list method.