2012-09-30 231 views
0

我一直在努力工作一段时间,试图在Google App Engine上安装SimpleAuth,并且遇到麻烦。首先在示例代码的底部,他们有这个:安装SimpleAuth for GAE时遇到问题

def _get_consumer_info_for(self, provider): 
     """Should return a tuple (key, secret) for auth init requests. 
     For OAuth 2.0 you should also return a scope, e.g. 
     ('my app id', 'my app secret', 'email,user_about_me') 

     The scope depends solely on the provider. 
     See example/secrets.py.template 
     """ 
     return secrets.AUTH_CONFIG[provider] 

我没有看到秘密文件,也没有看到它应该做什么。

然后除了这个小问题,我很好奇我应该如何呈现供应商和他们的登录URL给用户。本页面:https://github.com/crhym3/simpleauth/blob/master/example/handlers.py对常规设置有很好的描述,但它没有任何描述,我们实际需要传递给用户以让他们登录。

谢谢!

回答

1

首先,请注意,这只是一个示例,因此为演示目的简化了一些代码部分。

secrets是一个单独的模块。自述文件说要将secrets.py.template复制到secrets.py并设置适当的客户端/消费者ID和密码。同样,请参阅自述文件以了解从哪里获取不同提供商的客户/机密信息。

渲染取决于你。我所做的an example是这样的:

<p>Try logging in with one of these:</p> 
<a href="/auth/google">Google</a> 
<a href="/auth/facebook">Facebook</a> 
<a href="/auth/openid?identity_url=me.yahoo.com">Yahoo! (OpenID)</a> 
<a href="/auth/twitter">Twitter</a> 
<a href="/auth/linkedin">LinkedIn</a> 
<a href="/auth/windows_live">Windows Live</a> 

这些/auth/...链接应该被路由到您的处理(一般webapp2.RequestHandler或某些子类)这是混在SimpleAuthHandler

您可以在https://simpleauth.appspot.com上看到示例应用程序,希望能够澄清事情。

+0

感谢您的有益的职位。这清除了我的一个重要问题,但是我已经阅读了自述文件,而且我没有看到任何名为secrets.py的文件,这导致了一些混淆。这是我们应该自己创建的文件吗? – clifgray

+0

是的。有一个模板,你可以从什么开始,完全相同的secretts.py。这是example/secrets.py.template:https://github.com/crhym3/simpleauth/blob/master/example/secrets.py.template只需将其复制到secrets.py(没有“.template”结尾)并修改它,即设置真正的客户/秘密。 – alex