Instagram API - 无法请求访问令牌

时间:2015-11-05 10:05:35

标签: ruby-on-rails instagram-api httparty

使用 HTTParty 我尝试请求访问令牌,如下所示:

result = HTTParty.post("https://api.instagram.com/oauth/access_token",
{ 
  :body => [ { "client_id" => xxxxxxxxxx, "client_secret" => xxxxxxxxxxxxx,
  "grant_type" => "authorization_code",
  "redirect_url" => 'http://localhost:4000/access_token', "code" => xxxxxxxx } ].to_json,
  :headers => { 'Content-Type' => 'application/json', 'Accept' => 'application/json'}
})

但是回复说#400,“error_type”=>“OAuthException”,“error_message”=>“你必须提供client_id”},@ response =#,@ headers = {“content -language“=> [”en“],”expires“=> [”星期六,2000年1月1日00:00:00 GMT“],........

无法弄清楚原因..帮助!

1 个答案:

答案 0 :(得分:1)

您可以将内容类型更改为:

'Content-Type' => 'application/x-www-form-urlencoded'

有关详情,请点击instagram-api-authentication-must-provide-client-id

我希望这对你有所帮助。