문제

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?

도움이 되었습니까?

해결책

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

다른 팁

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
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top