在编写了一些开放 ID 身份验证的测试代码后,我休息了一下,当我回来时,发现自己面临着来自 GAE 的这个奇怪的警告信息:
Error: Unauthorized
Your client does not have permission to the requested URL /.
这是我用于 .pl 代码和 .yaml 的代码
version: 1
runtime: python
api_version: 1
builtins:
- remote_api: on
handlers:
- url: /
script: do_openid_login.py
login: required
auth_fail_action: unauthorized
- url: /_ah/login_required
script: do_openid_login.py
login: required
auth_fail_action: unauthorized
和
class MyLogin(webapp.RequestHandler):
def get(self):
user = users.get_current_user()
if user:
greeting = ("Welcome, %s %s %s! (<a href=\"%s\">sign out</a>)" %
(user.nickname(), user.email(), user.user_id(), users.create_logout_url("/")))
else:
greeting = ("<a href=\"%s\">Sign in or register</a>." %
users.create_login_url("/"))
self.response.out.write("<html><body>%s</body></html>" % greeting)
application = webapp.WSGIApplication([
('/', MyLogin),
], debug=True)
def main():
run_wsgi_app(application)
if __name__ == '__main__':
main()
有什么改变了吗?还是我做了一些愚蠢的事情?谢谢。