在java中获取谷歌的电子邮件/用户名?
是否可以检索我已使用 OAuth 成功验证的 Google 帐户的用户名?
我已检索到用户访问令牌,但我想知道它们是否是我可以进行的 API 调用 https://google.api /getUserName 并将访问令牌传递给该调用并成功检索用户电子邮件/用户名?
在普通的 OAuth Web 服务中,您只需要秘密和 ID 访问令牌即可调用 Web 服务,但在 google 中,您还需要用户名。
有什么想法吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
查看 http://sites.google.com/site/oauthgoog/Home/emaildisplayscope 。那应该对你有用。
Take a look at http://sites.google.com/site/oauthgoog/Home/emaildisplayscope . That should work for you.
到目前为止我想到的唯一方法是使用 Spreadsheet API。
如果您请求 Feed,则会列出所有文档
https://spreadsheets.google .com/feeds/spreadsheets/private/full?alt=json
还有一个包含用户名的字段:
不幸的是,这意味着提示用户授予对其 GDocs 帐户的访问权限,这可能会令人困惑..
但是我不知道 Google 是否有任何 API 可以直接获取用户名。
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:
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.
最好的方法是从联系人数据 API 检索以下 Feed:
https://www.google.com/m8/feeds/contacts/default/full?alt=json&max-results=0
并从 Feed 中获取下一个字段:
或
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:
or
http://code.google.com/intl/ja /apis/accounts/docs/AuthForInstalledApps.html#Errors
这是 PHP,我认为 JAVA 稍加修改就可以完成此练习
http://www.electrictoolbox.com/google-analytics-login-php-curl-username-password/< /a>
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/