Skip to content

Commit

Permalink
Handle authorization problems when fetching contacts.
Browse files Browse the repository at this point in the history
  • Loading branch information
oggy committed Jun 28, 2010
1 parent d3a10dc commit 028e12a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
8 changes: 7 additions & 1 deletion lib/contacts/google.rb
Expand Up @@ -22,7 +22,13 @@ def contacts(options={})
params = {:limit => 200}.update(options)
google_params = translate_parameters(params)
query = params_to_query(google_params)
response = @access_token.get("/m8/feeds/contacts/default/thin?#{query}")
begin
response = @access_token.get("/m8/feeds/contacts/default/thin?#{query}")
rescue OAuth::Unauthorized => error
# Token probably expired.
@error = error.message
return nil
end
parse_contacts(response.body)
end

Expand Down
8 changes: 7 additions & 1 deletion lib/contacts/yahoo.rb
Expand Up @@ -27,7 +27,13 @@ def contacts(options={})
guid = @access_token.params['xoauth_yahoo_guid']
uri = URI.parse("http://social.yahooapis.com/v1/user/#{guid}/contacts")
uri.query = params_to_query(yahoo_params)
response = @access_token.get(uri.to_s)
begin
response = @access_token.get(uri.to_s)
rescue OAuth::Unauthorized => error
# Token probably expired.
@error = error.message
return nil
end
parse_contacts(response.body)
end

Expand Down

0 comments on commit 028e12a

Please sign in to comment.