Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get user info via Google API

Is it possible to get information from user's profile via Google API? If it is possible, which API should I use?

I'm interesting in such information:

  • Url to the user profile (e.g. https://profiles.google.com/115063121183536852887);
  • Gender (sex);
  • Profile photo.

Also it would be cool to get other information from user's profile.

like image 483
glagola Avatar asked Aug 20 '11 08:08

glagola


People also ask

How can I get user information from OAuth?

If the authorization server supports OpenID Connect, there are two standard ways to get user information. One is to request the authorization server to issue an ID token which contains user information. The other is to access UserInfo Endpoint. See OpenID Connect Core 1.0 for details.

What data can I get from Google login?

After you have signed in a user with Google using the default scopes, you can access the user's Google ID, name, profile URL, and email address.


1 Answers

Add this to the scope - https://www.googleapis.com/auth/userinfo.profile

And after authorization is done, get the information from - https://www.googleapis.com/oauth2/v1/userinfo?alt=json

It has loads of stuff - including name, public profile url, gender, photo etc.

like image 96
Abhinav Manchanda Avatar answered Sep 20 '22 17:09

Abhinav Manchanda