在Google App Engine中生成独特且不透明的用户ID [英] Generating unique and opaque user IDs in Google App Engine

查看:115
本文介绍了在Google App Engine中生成独特且不透明的用户ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作一个应用程序,允许注册用户创建或上传内容,并允许匿名用户查看该内容并浏览注册用户的网页以查找该内容 - 这与Flickr等网站非常相似例如,允许用户浏览其用户的页面。



为此,我需要一种方法来标识匿名HTTP GET请求中的用户。用户应该能够输入 http://myapplication.com/browse/<userid>/<contentid> 并进入正确的页面 - 应该是唯一的,但由于隐私原因,不得像用户的电子邮件地址。

通过Google App Engine,我可以获取与用户关联的电子邮件地址,但正如我所说的,我不想使用它。我可以让我的应用程序的用户在注册时选择一个唯一的用户名,但是我希望尽可能将其作为可选项,以便注册过程尽可能短。

另一个选项是在注册过程中生成一些随机cookie(一个GUID?),并使用它,我没有看到明确的方式来保证这种唯一性一个没有旅行到数据库的cookie。

有没有一种方法可以让App Engine用户对象获得该对象的唯一标识符办法?



我正在寻找Python解决方案 - 我忘了GAE现在也支持Java。不管语言如何,我都希望这些技术是相似的。

解决方案

你的时间是无可挑剔的:就在昨天,发布了SDK,支持唯一的永久用户ID 。他们符合您指定的所有标准。


I'm working on an application that lets registered users create or upload content, and allows anonymous users to view that content and browse registered users' pages to find that content - this is very similar to how a site like Flickr, for example, allows people to browse its users' pages.

To do this, I need a way to identify the user in the anonymous HTTP GET request. A user should be able to type http://myapplication.com/browse/<userid>/<contentid> and get to the right page - should be unique, but mustn't be something like the user's email address, for privacy reasons.

Through Google App Engine, I can get the email address associated with the user, but like I said, I don't want to use that. I can have users of my application pick a unique user name when they register, but I would like to make that optional if at all possible, so that the registration process is as short as possible.

Another option is to generate some random cookie (a GUID?) during the registration process, and use that, I don't see an obvious way of guaranteeing uniqueness of such a cookie without a trip to the database.

Is there a way, given an App Engine user object, of getting a unique identifier for that object that can be used in this way?

I'm looking for a Python solution - I forgot that GAE also supports Java now. Still, I expect the techniques to be similar, regardless of the language.

解决方案

Your timing is impeccable: Just yesterday, a new release of the SDK came out, with support for unique, permanent user IDs. They meet all the criteria you specified.

这篇关于在Google App Engine中生成独特且不透明的用户ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆