oauthgoogle-apiuserinfo

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:

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


Solution

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

    And after authorization is done, pass the access token to this endpoint in a GET request: https://www.googleapis.com/oauth2/v1/userinfo?alt=json ,

    curl -X GET \
      "https://www.googleapis.com/oauth2/v1/userinfo?alt=json" \
      -H "Authorization: Bearer $TOKEN"
    

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