【问题标题】:Trouble with authorization using client_credentials Azure AD Graph API使用 client_credentials Azure AD Graph API 的授权问题
【发布时间】:2014-05-22 19:36:17
【问题描述】:

我正在尝试将 OAuth client_credentialsWindows Microsoft Azure 一起使用。我可以成功生成access_token,但是当我尝试访问https://graph.windows.net/mydomain.com/users?api-version=2013-04-05 时得到403 Forbidden

我做错了什么?我想我没有要求获得足够授权的access_token,但我找不到/猜测其他resource 或要添加的参数。

我目前的流程

请求

> POST /mydomain.com/oauth2/token HTTP/1.1
> Host: login.windows.net
> Content-Type: application/x-www-form-urlencoded
grant_type=client_credentials
&client_id={client_id}
&client_secret={client_secret}
&resource=https://graph.windows.net

回应

< HTTP/1.1 200 OK
< Content-Type: application/json; charset=utf-8
{
  "access_token": "<string>",
  "token_type": "Bearer",
  "expires_in": "<seconds>",
  "expires_on": "<timestamp>",
  "resource": "https://graph.windows.net"
}

请求

> GET /mydomain.com/users
>   ?api-version=2013-04-05 HTTP/1.1
> Host: graph.windows.net
> Authorization: Bearer {access_token}

回应

< HTTP/1.1 403 Forbidden
{
  "odata.error": {
    "code": "Authorization_RequestDenied",
    "message": {
        "lang": "en",
        "value": "Insufficient privileges to complete the operation."
    }
  }
}

注意:如果我错过了{access_token},我会得到 403 Unauthorized。

【问题讨论】:

  • 这是针对 Web 应用程序还是本地客户端应用程序?另外,您在门户的“其他应用程序的权限”下拉菜单中选择了什么?
  • @SeanOsterberg 非常出色。提交正确的答案,我会接受。谢谢。

标签: azure active-directory oauth-2.0


【解决方案1】:

根据我的评论,您需要确保从门户中的“其他应用程序的权限”下拉菜单中选择了正确的权限,否则将不会授予访问权限。请参阅this page in the documentation 了解更多信息。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-03-01
    • 1970-01-01
    • 2017-07-02
    • 1970-01-01
    • 2016-08-02
    • 1970-01-01
    • 2016-09-13
    • 1970-01-01
    相关资源
    最近更新 更多