我在尝试获取新的刷新令牌时遇到此错误:
{"error"=>"invalid_request","errordescription"=>"必需参数缺少:grant_type"}
以下是我用来生成请求的代码:
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"
})
尽管包含了grant_type参数,但我仍然会收到错误。有什么想法吗?
发布后不久发现答案:
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"
}
})