【发布时间】:2014-05-22 19:36:17
【问题描述】:
我正在尝试将 OAuth client_credentials 与 Windows 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