2017-08-19 31 views
0

我使用RESTClient实现创业板,下面是我的命令红宝石POST请求使用基本身份验证和多个数据

curl -H 'Authorization: Basic ENCODED_CLIENT_CREDENTIALS' --data '[email protected]&password=test&grant_type=password&scope=user%20documents%20user%2Fdocumentsv2' https://api.com/oauth2/token 

我不要通过以下RestClient翻译,这是我的代码:

access = RestClient::Request.new(
     :method => :post, 
     :url => 'https://api.com/oauth2/token', 
     :data => { 
      :username => 'xxxx', 
      :password => 'xxxx', 
      :grant_type => 'password' 
     }, 
     :headers => { 
      :Authorization => "Basic some_string", 
      :'Content-Type' => 'application/x-www-form-urlencoded' 
     } 
    ) 

显示400个不良要求。 任何人都可以为此翻译提供帮助。

感谢

回答

0

错误下面

:data => { 
    :username => 'xxxx', 
    :password => 'xxxx', 
    :grant_type => 'password' 
}, 

这条线可以使用​​,而不是data象下面这样:

:payload => { 
    :username => 'xxxx', 
    :password => 'xxxx', 
    :grant_type => 'password' 
}, 

我希望帮你。

相关问题