【发布时间】:2015-04-11 01:10:09
【问题描述】:
我已经设置了一个 Azure AD 应用程序,我想将它与我的 Web 应用程序一起使用。我使用以下步骤获得了 oAuth 令牌:
首先我要了我的授权码:
https://login.windows.net/common/oauth2/authorize?redirect_uri={REDIRECT_URI}&client_id={CLIENT_ID}&response_type=code&state=o365&prompt=admin_consent
这会将用户带到 login.windows.net 页面,他们必须接受我的应用程序将在其 AD 上使用的权限。
之后,我使用此端点https://login.windows.net/common/oauth2/token 和此有效负载使用 C# 获取 oAuth 令牌:
{"code": {AUTH_CODE}},
{"state", {STATE}},
{"grant_type", "authorization_code"},
{"redirect_uri", "{REDIRECT_URI}"},
{"client_id", "1ff78c4b-414f-44c7-834b-09bdae96f440"},
{"client_secret", "{CLIENT_SECRET}"},
{"resource", "https://graph.windows.net"}
一切都恢复正常,我得到了我的 oAuth 令牌。但是,当我尝试使用令牌卷曲 Graph API 时,出现此错误
curl https://graph.windows.net/{tenant}/users?api-version=1.5 -H "Authorization: Bearer [AUTH_TOKEN]"
{"odata.error":{"code":"Authorization_RequestDenied","message":{"lang":"en","value":"Insufficient privileges to complete the operation."}}}
我已经尝试了 {tenant} 的实际域、“me”别名和“myorganization”别名,但它们都不起作用。 “我”别名返回一个错误,指出“用户”资源不存在。我对这里的问题感到困惑
【问题讨论】:
-
嗨,马特。您的应用程序请求什么权限?例如,默认的“登录并阅读我的个人资料”不允许应用读取其他用户的个人资料信息。