通过他们的user_id获取Google App Engine用户 [英] Get a Google App Engine user by their user_id
问题描述
在 GAE 中,您可以查找 .google.com / appengine / docs / python / users / userclass.htmlrel =nofollow noreferrer> User
c> user_id ?
换句话说,是否有相当于:
from google.appengine.api.users import User
$对于这个问题,这似乎是互联网上唯一的帖子,而且自从我寻找解决方案以来,我以为自己的解决方案已经成为了解决方案的一个重要组成部分。 d发布我在这里找到的内容。
$ b $ user = User.get_by_id(user_id)
有关使用UserProperty的amir75说得很好,用于存储由google.appengine.users模块返回的User对象本身。
但如果您需要通过查找用户user_id 字段而不是默认的电子邮件字段,通常类似于
user = User(email ='validmail@gmailorgapps.com')
您可以使用它通过user_id进行查询。
user = User(_user_id ='validuserid')
有效的user_id是您之前从调用user.user_id()$ c $
我不确定amir75指的是有权访问所有谷歌帐户,因为返回的User对象只有电子邮件地址和昵称,而且只有当用户授权应用程序访问该信息时也是如此。
我的使用案例是我希望人们在网站上注册,但他们需要管理员来确认他们使用该网站。管理员用于确认用户的表单可以使用电子邮件ID作为字段来标识用于确认用户的复选框,但假定可能更改,user_id似乎是更安全的字段。
In GAE, can you look up a
User
with the User object'suser_id
?In other words, is there something equivalent to:
from google.appengine.api.users import User user = User.get_by_id(user_id)
解决方案This seems to be the only post on the internet regarding this and since I was looking for a solution, I thought I'd post what I found here.
What amir75 said about using the UserProperty is fine for storing the User object itself returned by the google.appengine.users module.
But if you need to lookup a User by the user_id field instead of the default email field, usually something like
user = User(email = 'validmail@gmailorgapps.com')
You can use this to query by user_id.
user = User(_user_id = 'validuserid')
The valid user_id is something that you got earlier from callinguser.user_id()
I'm not sure what amir75 is referring to about having access to all google accounts since the User object returned will only have the email address and nickname, and that too only if the user authorizes the application to access that information.
My use case for this is I want people to sign up on the site, but they need an administrator to confirm them for using the site. The form used by the administrator for confirming the users can use email id as the field to identify the checkbox for confirming the user, but given that it might change, the user_id seems to be a safer field to use.
这篇关于通过他们的user_id获取Google App Engine用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!