【问题标题】:Youtube: {"error"=>"invalid_request", "error_description"=>"Required parameter is missing: grant_type"}Youtube: {"error"=>"invalid_request", "error_description"=>"缺少必需参数:grant_type"}
【发布时间】:2016-04-04 18:49:45
【问题描述】:

我在尝试获取新的刷新令牌时收到此错误:

{"error"=>"invalid_request", "error_description"=>"必填参数 缺少: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 参数,但我仍然收到错误消息。任何想法为什么?

【问题讨论】:

    标签: ruby youtube-api httparty


    【解决方案1】:

    发布后不久发现了答案:

    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"
      }
    })
    

    【讨论】:

      猜你喜欢
      • 2017-12-01
      • 2012-06-27
      • 1970-01-01
      • 1970-01-01
      • 2019-12-11
      • 1970-01-01
      • 2014-06-29
      • 2021-05-13
      • 2019-09-14
      相关资源
      最近更新 更多