所以我试图为我的GAE应用程序创建自己的openID登录,但我遇到了一些问题。当我在我的localhost上运行它时它运行正常但是当我尝试部署它时它不会运行。我认为这是因为它实际上并没有尝试到达我的localhost上的openID服务器。
这是我的错误:
File "/base/data/home/apps/s~exployretrial/1.359795154076948420/blog.py", line 97, in get
providerlist.append(users.create_login_url(federated_identity=uri))
File "/base/python27_runtime/python27_lib/versions/1/google/appengine/api/users.py", line 246, in create_login_url
req.set_federated_identity(federated_identity)
File "cpp_message.pyx", line 124, in cpp_message.SetScalarAccessors.Setter (third_party/apphosting/python/protobuf/proto1/cpp_message.cc:2229)
TypeError: <type 'tuple'> has type <type 'tuple'>, but expected one of: str, unicode
这是我的python代码:
providers = {
'Google' : 'www.google.com/accounts/o8/id', # shorter alternative: "Gmail.com"
'Yahoo' : 'yahoo.com',
'MySpace' : 'myspace.com',
'AOL' : 'aol.com',
'MyOpenID' : 'myopenid.com'
# add more here
}
class Login(BlogHandler):
def get(self):
user = users.get_current_user()
providerlist = []
if user: # signed in already
self.redirect('/home')
else: # let user choose authenticator
for uri in providers.items():
providerlist.append(users.create_login_url(federated_identity=uri))
self.render('login.html', user = user, providerlist = providerlist)
HTML代码:
<ul>
{% for provider in providerlist %}
{% if loop.index == 1 %}
<li><a href="{{ provider }}"><img src="http://openid.net/wordpress-content/uploads/2007/10/aol.png"></a></li>
{% elif loop.index == 2 %}
<li><a href="{{ provider }}"><img src="http://openid.net/images/get-logos/google.png"></a></li>
{% elif loop.index == 3 %}
<li><a href="{{ provider }}"><img src="http://openid.net/wordpress-content/uploads/2009/11/yahoo.png"></a></li>
{% elif loop.index == 4 %}
<li><a href="{{ provider }}"><img src="http://openid.net/images/get-logos/myopenid.png"></a></li>
{% elif loop.index == 5 %}
<li><a href="{{ provider }}"><img src="http://openid.net/wordpress-content/uploads/2007/10/logo_myspace_s.gif"></a></li>
{% endif %}
{% endfor %}
</ul>
因此,如果您需要更多信息,我们将非常感谢任何见解,并告诉我。
谢谢!
答案 0 :(得分:1)
从GAE上的应用程序设置中,将Authentication Options
更改为(Experimental) Federated Login
而不是Google Accounts API
。