簡體   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