FIWARE-Lab KeyRock访问令牌请求错误

时间:2015-07-09 15:50:23

标签: fiware filab

我正在使用DHC Web客户端在FIWARE-Lab上的KeyRock GE实例上测试授权代码授予协议。

到目前为止,我已经成功实现了授权请求,并获得了用于访问令牌请求的代码。授权请求的URL如下(虽然没有在DHC上执行,但在常规浏览器上执行,因此我可以介绍我的用户和密码):

https://account.lab.fiware.org/oauth2/authorize/?response_type=code&client_id=2122&redirect_uri=http%3A%2F%2Flocalhost%2FCallback

我已经检查过client_id和redirect_uri是否正确对付与我在FIWARE-Lab帐户中的应用程序相关的值。

执行以下请求(无法发布图片,因此我将描述)

POST
https:// account.lab.fiware.org/oauth2/token?grant_type=authorization_code&code=<code>&redirect_uri=http%3A%2F%2Flocalhost%2FCallback -- <code> is the code obtained on the Auth. Request
Authorization: Basic <XXXX> --- <XXXX> is the result of base64(client_id+":"+client_secret)
Content-Type: application/x-www-form-urlencoded

...我收到以下错误消息:

{
"error":{
"message": "create_access_token() takes exactly 3 arguments (2 given)",
"code": 400,
"title": "Bad Request"
}
}

我已经检查了授权是否正确(使用我的应用程序中的OAuth凭据进行了基本操作),并且我使用了与之前的授权请求相同的redirect_uri,以及从中获取的代码。

¿出了什么问题?

P.S。:如果我删除任何或所有查询参数,我仍然会得到相同的错误

2 个答案:

答案 0 :(得分:2)

不要传递网址中的参数。相反,将它们作为查询字符串添加到请求的正文中:

POST /oauth2/token HTTP/1.1
Host: account.lab.fiware.org
Content-Type: application/x-www-form-urlencoded
Authorization: Basic <XXXX> --- <XXXX>
Cache-Control: no-cache
Content-Type: application/x-www-form-urlencoded

grant_type=authorization_code&code=1234&redirect_uri=http%3A%2F%2Flocalhost%3A9000%2Fcodecallback.html

答案 1 :(得分:0)

我建议按照演示文稿中的步骤进行操作:

Adding Identity Management and Access Control to your Application

它为您提供了有关您必须遵循的不同请求的详细信息,以及它们的预期响应。