如何使用 GData 检索用户的电子邮件地址?
我正在尝试使用 GData 检索刚刚使用 Google OAuth 授权我的网站的用户的电子邮件地址、真实姓名和个人资料 URL。
我们知道如何使用 Google 的 OpenID 流程请求它,但 OpenID 流程有一个严重的限制,即我们必须先询问 Google Apps 用户的域,然后才能知道将他们发送到何处登录。至少使用 OAuth(甚至 AuthSub) ,系统会提示用户输入要登录的 Google 帐户。
I'm trying to use GData to retrieve the email address, real name, and profile URL of the user that just authorized my site using Google OAuth.
We know how to request it using Google's OpenID flow, but the OpenID flow has the severe limitation that we have to ask for a Google Apps user's domain before we know where to send them to log in. At least using OAuth (or even AuthSub), the user gets prompted for which of their Google accounts to log in.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
仍不清楚这是否可行,但我们现在通过使用 OpenID 流程来解决它。随着他们的通用登录流程的增加,我们不再有理由避开他们的 OpenID 流程。
Still not clear that this is possible, but we now work around it by using the OpenID flow. With the addition of their universal login flow, we no longer have reason to avoid their OpenID flow.
如果您获取用户的联系人供稿,则可以访问为您提供电子邮件和姓名的
authors
字段。此外,提要的id
字段似乎是联系人所有者的电子邮件地址。名称已更改的示例(在 Scala 中),假设 AuthSub 的用户(抱歉,我没有将代码迁移到 OAuth),其中您已经拥有会话
令牌
:If you fetch the user's contacts feed, you can access the
authors
field which gives you email and name. Additionally, the feed'sid
field appears to be the email address of the person who owns the contacts.An example (in Scala) with names changed, assuming the user of AuthSub (sorry, I've not migrated my code to OAuth) where you already have a session
token
: