【问题标题】:FIWARE-Lab KeyRock Access Token Request errorFIWARE-Lab KeyRock 访问令牌请求错误
【发布时间】:2015-07-09 15:50:22
【问题描述】:

我正在使用 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.:如果我删除任何或所有查询参数,我仍然会得到同样的错误

【问题讨论】:

    标签: fiware filab


    【解决方案1】:

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

    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
    

    【讨论】:

      【解决方案2】:

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

      Adding Identity Management and Access Control to your Application

      它为您详细介绍了您必须遵循的不同请求以及它们的预期响应。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2016-12-03
        • 2019-09-16
        • 1970-01-01
        • 2012-09-06
        • 1970-01-01
        • 2017-07-20
        • 1970-01-01
        • 2022-01-05
        相关资源
        最近更新 更多