Youtube: {"error"=>"invalid_request", "error_description"=>"Required parameter is missing: grant_type"}

时间:2016-04-04 18:49:46

标签: ruby youtube-api httparty

I am getting this error when trying to get a new refresh token:

{"error"=>"invalid_request", "error_description"=>"Required parameter is missing: grant_type"}

Here's the code I'm using to generate the request:

HTTParty.post("https://accounts.google.com/o/oauth2/token", 
{
  client_id: Figaro.env.google_client_id,
  client_secret: Figaro.env.google_client_secret,
  refresh_token: Figaro.env.google_client_refresh_token,
  grant_type: "refresh_token"
})

Despite including the grant_type param, I'm still getting the error. Any ideas why?

1 个答案:

答案 0 :(得分:0)

Discovered the answer shortly after posting:

HTTParty.post("https://accounts.google.com/o/oauth2/token", 
{
  :body => {
    client_id: Figaro.env.google_client_id,
    client_secret: Figaro.env.google_client_secret,
    refresh_token: Figaro.env.google_client_refresh_token,
    grant_type: "refresh_token"
  }
})