【问题标题】:Get authorization for google drive api calls in ruby with HTTParty使用 HTTParty 在 ruby​​ 中获取 google drive api 调用的授权
【发布时间】:2017-09-12 22:56:49
【问题描述】:

我想获得授权访问权限,用于 google drive api 调用。

我使用 ruby​​ 和 HTTParty gem。

我遵循了这个快速入门示例:https://developers.google.com/drive/v3/web/quickstart/ruby

然后,我想使用 HTTParty 来使用这个 API,我知道我必须通过上面的凭据获得用户的 access_token 来获得授权,但是当我尝试这个代码时HTTParty.get('https://www.googleapis.com/drive/v3/about', headers: {'Authorization' => "Bearer #{service.authorization.access_token}"})

我有这个错误状态: ...."code"=>400, "message"=>"The 'fields' parameter is required for this method."}}, @response=#<Net::HTTPBadRequest 400 Bad Request readbody=true>,....

我的目标是对 Google Drive API 的使用进行一些测试。

我应该如何获得此 API 的授权访问权限?

【问题讨论】:

    标签: ruby google-drive-api httparty


    【解决方案1】:

    我找到了问题的答案!

    我的错误不在授权上,而是在我忘记的字段请求参数上!

    例如HTTParty.get('https://www.googleapis.com/drive/v3/about?fields=kind,user', headers: {'Authorization' => "Bearer #{service.authorization.access_token}"})

    感谢这份文档:

    https://developers.google.com/drive/v3/web/performance?authuser=0#partial

    再见!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-09-06
      • 2015-12-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-09-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多