2017-06-14 71 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"