1

We're using Oauth to grab Calendar event data. I have successfully authorized the token and exchange it for an access token. When I perform a get request to the API endpoint I get a page that says "Moved Temporarily" with a link to something like https://www.google.com/calendar/feeds/default?gsessionid=xxxxxxxxxxxx

I'd like to interpret the response, whether it's json or xml but I can't get beyond the redirect it's throwing out. Any idea how to follow this?

Here's my call to the feed:

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

1 回答 1

2

是的,只是我自己处理了这个。它说“暂时移动”,因为它是一个重定向,不幸的是 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打补丁......

于 2011-02-25T21:52:45.400 回答