【发布时间】:2020-01-15 18:15:54
【问题描述】:
我有一个内部应用程序,用户应该能够使用我们公司的 G Suite 凭据登录。我在 G Suite 中创建了几个自定义角色,我计划在应用中使用它们来确定他们可以在那里做什么。
我正在使用 Passport 进行 OAuth2 调用,我使用的范围如下:
scope: [
'email',
'https://www.googleapis.com/auth/userinfo.profile',
'https://www.googleapis.com/auth/admin.directory.rolemanagement.readonly'
]
列表中的最后一个授予我列出在我的应用中登录用户的所有角色的权限。
然后我调用https://www.googleapis.com/admin/directory/v1/customer/<MY_CUSTOMER_ID>/roleassignments?userKey=<MY_USER_ID> 并获取用户分配给他们的角色列表。
问题是,如果我使用我的超级管理员用户,一切都会很好,但是当使用没有超级管理员权限的测试用户时,我会从 Google API 获得以下信息:
{
errors: [
{
domain: 'global',
reason: 'forbidden',
message: 'Not Authorized to access this resource/api'
}
],
code: 403,
message: 'Not Authorized to access this resource/api'
}
我很确定我需要授予对 G Suite 中创建的自定义角色的一些访问权限,但我不知道该怎么做。我尝试在角色管理员权限视图中勾选所有内容,但没有任何效果。只有当我授予我的测试帐户超级管理员权限时,才能调用 Google API。
【问题讨论】:
标签: google-api google-oauth google-workspace