Getting user profile with google oauth2

altunyurt picture altunyurt · Oct 1, 2011 · Viewed 14.7k times · Source

I'm trying to get user profile information upon logging in with google-oauth2. User successfully logs in and i can get the access_token and can refresh the token when needed. Though i could not manage to get any information about the user despite reading the docs and trying for hours.

From "Retrieving profiles" section of developers guide :

https://www.google.com/m8/feeds/profiles/domain/domainName/full

should be enough. i've tried with "gmail.com", "google.com", "gmail", "google", "orkut", "orkut.com" , myregisteredappsdomainname (and .com) as domainName. i've also tried it with

https://www.google.com/m8/feeds/profiles/domain/domainName/full?access_token=access_token_for_user

all i managed to get was 401 error, where it says "That’s an error.". Regarding 401 error, I've refreshed the token and tried again with new token, but kept getting 401s.

How can i get profile information and image address for user upon logging in?

Answer

Sergio Rosas picture Sergio Rosas · Mar 21, 2012

The scope you're looking for is:

https://www.googleapis.com/oauth2/v1/userinfo

This has been already answered here