2017-06-14 44 views
0

我試圖執行https://github.com/doorkeeper-gem/doorkeeper/wiki/Interacting-as-an-OAuth-client-with-Doorkeeper#writing-a-raw-oauth-client所述的oauth2流程,但是當我嘗試檢索訪問令牌時,我得到了一個401。下面是我在做什麼門衛認證流程不能正常工作

1)點擊應用程序授權按鈕這裏看到enter image description here 2)本人授權下一個屏幕上的應用程序,我給出了一個網址的形式chromiumapp.org/?code=eb775dba8811f605c672a0aac8472972eabaae87446ac957e2b71c57b0b10e6e

3鑑於這種代碼)我執行

curl -XPOST http://localhost:3000/oauth/token -d '{ 
    "client_id": CLIENT_ID, 
    "client_secret": CLIENT_SECRET, 
    "redirect_uri": "https://galaiojniedmogfplghkjnmcfnlbpbpg.chromiumapp.org/", 
    "grant_type": "authorization_code", 
    "code": "eb775dba8811f605c672a0aac8472972eabaae87446ac957e2b71c57b0b10e6e" 
}` 

然而,這將返回{"error":"invalid_request","error_description":"The request is missing a required parameter, includes an unsupported parameter value, or is otherwise malformed."}

有沒有辦法,我失蹤或流的某些部分是有什麼incorr在文檔中?

回答

0

我已經更新了我上面鏈接的wiki,但是在其他人遇到此問題時,根據rfc,令牌請求上的參數必須爲urlencoded形式。

curl -XPOST http://localhost:3000/oauth/token 
    -F "client_id=CLIENT_ID" 
    -F "client_secret=CLIENT_SECRET" 
    -F "redirect_uri=https://galaiojniedmogfplghkjnmcfnlbpbpg.chromiumapp.org/" 
    -F "grant_type=authorization_code" 
    -F "code=eb775dba8811f605c672a0aac8472972eabaae87446ac957e2b71c57b0b10e6e"