繁体   English   中英

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

[英]FIWARE-Lab KeyRock Access Token Request error

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

到目前为止,我已经成功实现了授权请求,并且获得了用于访问令牌请求的代码。 授权请求的网址如下(尽管不是在DHC上执行,而是在常规浏览器上执行,所以我可以介绍我的用户名和密码):

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

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

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

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,以及从中获取的代码。

怎么了?

PS:如果删除任何或所有查询参数,我仍然会遇到相同的错误

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

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

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

向您的应用程序添加身份管理和访问控制

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM