简体   繁体   English

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

[英]FIWARE-Lab KeyRock Access Token Request error

I'm testing the Authorization Code Grant protocol on the instance of KeyRock GE at FIWARE-Lab using DHC web client. 我正在使用DHC Web客户端在FIWARE-Lab的KeyRock GE实例上测试授权码授予协议。

So far I have succeeded on implementing the Authorization Request, and I obtain the code to be used on the Access Token Request. 到目前为止,我已经成功实现了授权请求,并且获得了用于访问令牌请求的代码。 The URL for the Authorization Request is the following (although not executed on DHC, but on a regular browser so I can introduce my user and password): 授权请求的网址如下(尽管不是在DHC上执行,而是在常规浏览器上执行,所以我可以介绍我的用户名和密码):

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

I have checked that the client_id and the redirect_uri are both correct against the values related with my application at my account at FIWARE-Lab. 我已经在FIWARE-Lab的帐户中检查client_id和redirect_uri是否都与与我的应用程序相关的值正确。

Executing the following request (can't post images, so I'll describe) 执行以下请求(无法发布图片,因此我将进行描述)

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

...I get the following error message: ...我收到以下错误消息:

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

I've checked the authorization is correct (Basic using the OAuth credentials from my application), and I'm using the same redirect_uri used at the previous Authorization Request, and the code obtained from it. 我已经检查了授权是否正确(基本使用我的应用程序中的OAuth凭据),并且我使用的是先前授权请求中使用的相同redirect_uri,以及从中获取的代码。

¿What is wrong? 怎么了?

PS: If I remove any or all of the query parameters, I still get the same error PS:如果删除任何或所有查询参数,我仍然会遇到相同的错误

Don't pass the parameters in the url. 不要在网址中传递参数。 Instead, add them to request's body as query string: 而是将它们作为查询字符串添加到请求的正文中:

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

I suggest to follow the steps in the presentation: 我建议按照演示中的步骤进行操作:

Adding Identity Management and Access Control to your Application 向您的应用程序添加身份管理和访问控制

It gives you details about what are the different requests that you have to follow and also what are the expected response of them. 它为您提供了有关您必须遵循的不同请求的详细信息,以及它们的预期响应。

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

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