【问题标题】:How to get the the User ID from an email in GAE如何从 GAE 中的电子邮件中获取用户 ID
【发布时间】:2011-12-17 12:35:34
【问题描述】:

我正在开发一个小应用程序,它允许用户登录应用程序,允许应用程序 OAuth 访问服务,然后通过电子邮件使用应用程序与服务交互。

我已经使用 gdata 和 gdata.gauth 成功启用了 Oauth,并且可以在用户登录时轻松存储/恢复 Oauth 令牌和 user_id。

但是,在收到电子邮件时,我尝试通过创建 users.User(email="senders.email@gmail.com") 来获取 user_id,但最终得到的 user_id 值为 None。

即:

登录时:

current_user = users.get_current_user()
current_user.user_id() #this is a valid id when the user is logged in

接收电子邮件时(使用邮件处理程序):

current_user = users.User(email="sender.email@gmail.com")
current_user.user_id() #this returns None

关于如何完成这项工作的任何提示?

【问题讨论】:

    标签: python google-app-engine google-cloud-datastore gdata-api gdata


    【解决方案1】:

    阅读http://code.google.com/appengine/docs/python/users/userclass.html#User

    在方法调用user_id下,注意如果自己创建User对象,user_id字段会返回None。

    【讨论】:

    • 谢谢 - 我不敢相信我错过了这一点,即使我已经阅读了该页面大约 50 倍。我正在构建一个解决方法,使用数据存储将电子邮件地址与用户 ID 相关联,并从中重建 authtoken。非常感谢您的快速回复。对于那些处于同样困境的人,我使用stackoverflow.com/questions/5569074/… 来指导“重建”
    猜你喜欢
    • 2019-06-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-02-09
    • 1970-01-01
    • 2016-03-22
    • 1970-01-01
    相关资源
    最近更新 更多