【问题标题】:Google Calendar Data API Integration谷歌日历数据 API 集成
【发布时间】:2011-06-10 03:12:40
【问题描述】:

我们正在使用 Oauth 来获取日历事件数据。我已成功授权令牌并将其交换为访问令牌。当我对 API 端点执行 get 请求时,我得到一个页面,上面写着“已临时移动”,其中包含指向 https://www.google.com/calendar/feeds/default?gsessionid=xxxxxxxxxxxx

之类的链接

我想解释响应,无论是 json 还是 xml,但我无法超越它抛出的重定向。知道如何遵循这个吗?

这是我对提要的调用:

    access_token = current_user.google.client
    response = access_token.get(ConsumerToken::GOOGLE_URL).body

【问题讨论】:

  • 您好,您使用哪个 Ruby 库访问 Google 文档?

标签: ruby-on-rails api oauth oauth-ruby


【解决方案1】:

是的,我自己处理了这个。它说“临时移动”,因为它是一个重定向,不幸的是 oauth gem 不会自动跟随。你可以这样做:

calendar_response = client.get "http://www.google.com/calendar/feeds/default"
if calendar_response.kind_of? Net::HTTPFound # a.k.a. 302 redirect
  calendar_response = client.get(calendar_response['location'])
end

这可能值得为 oauth 打补丁...

【讨论】:

  • 嗨,您使用哪个 Ruby 库来访问 Google 文档?
  • @Crashalot 我使用OAuth Ruby gemoauth-plugin
  • 谢谢!你这么多!这是我的 oauth 任务的最后一步,现在它可以工作了:-)。
猜你喜欢
  • 2019-05-12
  • 1970-01-01
  • 1970-01-01
  • 2016-08-30
  • 2015-02-18
  • 2016-04-15
  • 1970-01-01
  • 1970-01-01
  • 2016-01-03
相关资源
最近更新 更多