2

所以我试图为我的 GAE 应用程序创建自己的 openID 登录名,但我遇到了一个小问题。当我在本地主机上运行它时它运行良好,但是当我尝试部署它时它不会运行。我认为这是因为它实际上并没有尝试访问我的本地主机上的 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>

因此,任何见解将不胜感激,如果您需要更多信息,请告诉我。

谢谢!

4

1 回答 1

1

从 GAE 上的应用程序设置中将 更改Authentication Options(Experimental) Federated Login而不是Google Accounts API.

于 2012-06-22T05:33:16.027 回答