【发布时间】:2016-08-10 12:36:41
【问题描述】:
我想查询用户组。根据https://graph.microsoft.io/en-us/docs/platform/rest我做了以下步骤:
-
获取代码
https://login.microsoftonline.com/common/oauth2/authorize? response_type=id_token%20code& client_id=<MY_CLIENT_ID>& redirect_uri=http%3A%2F%2Flocalhost%3A3000%2Fauth%2Fopenid%2Freturn response_mode=query& nonce=F8GtCajiXYKcGBtw& scope=openid%20https%3A%2F%2Fgraph.microsoft.com%2FGroup.Read.All%20Group.Read.All& resource=https%3A%2F%2Fgraph.microsoft.com%2F& state=HTlUWuV5su%2BG4zBE#
注意:提供了 3 个作用域(openid、Group.Read.All、https://graph.microsoft.com/Group.Read.All)
然后我登录,AAD 响应我的网站:
http://localhost:3000/auth/openid/return?
code=<Recieved_Code>&
id_token=<Recieved_id_Token>&
state=xxxx&
session_state=yyy
- 获取 access_token
这会返回 JSON
{
"token_type":"Bearer",
"scope":"User.Read",
"resource":"https://graph.microsoft.com/",
"access_token":<Access_token_in_here>,
... other fields
}
注意:仅返回 User.Read 范围
我使用步骤 2) 中的 access_token 进行查询
- 查询用户是否正常:https://graph.microsoft.com/v1.0/me/
- 查询组被禁止:https://graph.microsoft.com/v1.0/me/memberOf 并收到错误“权限不足,无法完成操作。”
那么为什么我请求 3 个作用域的权限,但只获得一个作用域的权限?
【问题讨论】:
-
范围组合 [openid, Group.Read.All] 或 [openid, xxxx/Group.Read.All] 也只返回“User.Read”
标签: office365 microsoft-graph-api azure-ad-graph-api