How to access Google contacts using OpenID in Ruby

I am using a login program with omniauth, authid. When a user logs in, I get

user_info: name: Riccardo Tacconi last_name: Tacconi email: email@gmail.com first_name: Riccardo uid: https://www.google.com/accounts/o8/id?id=xxxxxxxxx provider: google_apps 

I found the plugin: http://stakeventures.com/articles/2009/10/06/portable-contacts-in-ruby to get google contacts. I need to use this method:

 @client = PortableContacts::Client.new "http://www-opensocial.googleusercontent.com/api/people", @access_token 

but I need a token. I only have uid. Do you have an idea how to get an access token? There is no document on access to Google.

+6
ruby oauth rubygems openid
source share
1 answer

The answer to this question is rather complicated. The Pelle Portable Contacts analyzer relies on its oauth . You may be able to manually construct the token object (key / secret pair) from what omniauth / authid gives, but it will probably be quite dirty code.

Officially supported OAuth client for Ruby Signet . However, the Pelle parser was designed only for use with its OAuth implementation, so the story is about the same. You could snatch the analysis code from your client and marry him to Signet, but, as before, if you go down this route, your work will be cut out for you.

Probably the easiest task today is to simply use the oauth and accept the dependency tree that Pelle forced you to.

Edit: After a while, the google-api-client gem can provide you with what you need at that moment. It supports both OAuth 1 and 2, and offers access to some Google APIs in many cases. Unfortunately, the contacts API is currently not available in, but the client is still able to make API requests without using detection, although it is a bit more manual in this case (in that you need to pass HTTP requests to it that it will allow , and you are mostly on your own for parsing).

+3
source share

Source: https://habr.com/ru/post/649764/


All Articles