Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get basic profile info from google-api-client

I'm using the ruby google-api-client gem. I'm able to successfully OAuth and get back a access token. For the life of me, now that I have the token, I can't figure out how to get the basic profile info for the user.

My scope includes https://www.googleapis.com/auth/userinfo.email. How do I get this info from the client, or what google client library should I pull in to get this info?

Any help appreciated...this seems like a really simple request, yet I can't find it anywhere.

like image 910
theartofbeing Avatar asked Sep 08 '26 05:09

theartofbeing


1 Answers

require 'google/apis/oauth2_v2'
service = Google::Apis::Oauth2V2::Oauth2Service.new
service.tokeninfo(access_token: "Your Access Token").email

Source code here

like image 76
Iñaki Ibarra Avatar answered Sep 11 '26 10:09

Iñaki Ibarra



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!