在java中获取谷歌的电子邮件/用户名?

发布于 2024-10-03 02:45:02 字数 300 浏览 1 评论 0原文

是否可以检索我已使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

一百个冬季 2024-10-10 02:45:02

到目前为止我想到的唯一方法是使用 Spreadsheet API。

如果您请求 Feed,则会列出所有文档

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

还有一个包含用户名的字段:

response.data.feed.title.$t

不幸的是,这意味着提示用户授予对其 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:

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.

又怨 2024-10-10 02:45:02

最好的方法是从联系人数据 API 检索以下 Feed:

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

并从 Feed 中获取下一个字段:

response.data.feed.id

response.data.feed.author.name.$t
response.data.feed.author.email.$t

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文