Question

is it possible to retrieve the username of a google account that i have succesfully authenticated using OAuth?

i have retrieved the users Access tokens but i am wondering if their is a API call i can make such has https://google.api/getUserName and pass the access tokens to that call and succesfully retrieve the users email/username?

In a normal OAuth web service, all you need is the secret and id access tokens to make calls to the web service but in google you also need the username too.

Any ideas?

Was it helpful?

Solution

Take a look at http://sites.google.com/site/oauthgoog/Home/emaildisplayscope . That should work for you.

OTHER TIPS

The only way I figured so far is using the Spreadsheet API.

If you request the feed, that lists all documents

https://spreadsheets.google.com/feeds/spreadsheets/private/full?alt=json

There is a field with the username as well:

response.data.feed.title.$t

Unfortunately, this means prompting the user to grant access to his GDocs account, which may be confusing..

But I don't know of any API by Google to directly get the username.

Best way, the following feed was retrieved from the Contacts Data API:

https://www.google.com/m8/feeds/contacts/default/full?alt=json&max-results=0

and get next fields from the feed:

response.data.feed.id

or

response.data.feed.author.name.$t
response.data.feed.author.email.$t
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top