开发者

Get a google's email/username in java?

开发者 https://www.devze.com 2023-01-26 01:29 出处:网络
is it possible to retrieve the username of a google account that i have succesfully authenticated using OAuth?

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


http://code.google.com/intl/ja/apis/accounts/docs/AuthForInstalledApps.html#Errors

This one is PHP, i think a slight modification in JAVA could make this workout

http://www.electrictoolbox.com/google-analytics-login-php-curl-username-password/

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号