I'm working to use the google_contacts_api: https://github.com/aliang/google_contacts_api
I have the following code in user.rb:
google_contacts_user = GoogleContactsApi::User.new(self.authentications.first.token)
@x = google_contacts_user.contacts
self.authentications.first.token
is the token stored via omniauth-google-oauth2.
Problem is, this is erring:
undefined method `get' for #<String:0x007fce71ad54e8> Did you mean? gem
What am I doing wrong?
First install oauth2
gem install oauth2
And then create an Oauth2AccessToken instance from the token string
oauth2_object = OAuth2::AccessToken.new(self.authentications.first.token)
Now it should be possible to use this Oauth2AccessToken with the GoogleContacts gem:
GoogleContactsApi::User.new(oauth2_object)
I'm basing this on the gem's docs
You need to pass to the GoogleContactsApi::User constructor one of the following two objects:
an OAuth::AccessToken from the oauth-ruby gem an OAuth2::AccessToken from the oauth2 gem