【发布时间】:2014-10-14 01:03:40
【问题描述】:
我正在使用 Azure AD 处理 Authorization Code Grant Flow。尽管文档说 grant_type 应该是 authorization_code,但我收到了有关此属性的错误消息。
POST https://login.windows.net/SOME_AZURE_AD_UUID/oauth2/token?api-version=1.0
Content-Type: application/x-www-form-urlencoded
client_id=SECRET_CLIENT_ID
&client_secret=SECRET_CLIENT_SECRET
&code=SECRET_CODE
&grant_type=authorization_code
&redirect_uri=https://myserver.example.com/login/auth_return
&resource=https://myserver.example.com/
&scope=openid email
(编辑:为清楚起见添加了空格)
我回来的错误:
HTTP/1.1 400 Bad request
Content-Length: 436
X-Content-Type-Options: nosniff
X-Powered-By: ASP.NET
Request-Id: SOME_REQUEST_ID
X-Ms-Request-Id: SOME_REQUEST_ID
Strict-Transport-Security: max-age=31536000; includeSubDomains
Set-Cookie: x-ms-gateway-slice=slicea; path=/; secure; HttpOnly, stsservicecookie=acs; path=/; secure; HttpOnly
Server: Microsoft-IIS/8.0
Cache-Control: private
Date: Wed, 20 Aug 2014 14:44:08 GMT
Content-Type: application/json; charset=utf-8
{
"correlation_id": "SOME_CORRELATION_ID",
"error": "unsupported_grant_type",
"error_codes": [
70003
],
"error_description": "
ACS70003: The access grant 'authorization_code' is not supported.\r\n
Trace ID: SOME_TRACE_UUID\r\n
Correlation ID: SOME_CORRELATION_ID\r\n
Timestamp: 2014-08-20 14:44:08Z",
"timestamp": "2014-08-20 14:44:08Z",
"trace_id": "SOME_TRACE_UUID"
}
(为清楚起见添加了空格)
如果我将grant_type 更改为client_credentials,此请求确实有效(但我还没有找到一种方法来使用生成的令牌来满足我的需要)。如果我将一些 URL 更改为指向 Google 而不是 Azure AD,它也可以工作。
这些请求是否存在错误,或者服务是否真的不支持记录在案的grant_type 或authorization_code?
【问题讨论】:
标签: azure active-directory oauth-2.0