我正在尝试在我的应用程序上集成 twitter 登录,我写了这段代码
class AuthTwitterHandler(tornado.web.RequestHandler, tornado.auth.TwitterMixin):
@tornado.web.asynchronous
def get(self):
print 'GET'
if self.get_argument("oauth_token", None):
print 'GET OK'
self.get_authenticated_user(self.async_callback(self._on_auth))
return
print 'REDIRECT'
self.authenticate_redirect()
@tornado.web.asynchronous
def _on_auth(self, user):
print 'ONAUTH'
if not user:
print 'Broken'
raise tornado.web.HTTPError(500, "Twitter auth failed")
# Save the user using, e.g., set_secure_cookie()
print 'not Broken'
self.set_secure_cookie("user", tornado.escape.json_encode(user))
并且作为我的推特应用程序中的 callback_url 我放置了这个处理程序的相同地址,我的输出是:
GET
REDIRECT
GET
GET OK
ONAUTH
Broken
我的日志说:
2012-06-18 16:56:09,650 - root - INFO - Logging started
2012-06-18 16:56:09,821 - root - INFO - Server starting on port 443
2012-06-18 16:56:16,170 - root - INFO - 304 GET /auth (127.0.0.1) 0.72ms
2012-06-18 16:56:19,215 - root - INFO - 302 POST /auth (127.0.0.1) 1.35ms
2012-06-18 16:56:19,719 - root - INFO - 302 GET /auth/twitter (127.0.0.1) 429.17ms
2012-06-18 16:56:20,464 - root - WARNING - Missing OAuth request token cookie
2012-06-18 16:56:20,465 - root - WARNING - 500 GET /auth/twitter?oauth_token=Nbed9YQseoNC3YjdFkbOPS5An7OhfewcEgp3oPuq4&oauth_verifier=uGWWoItQ7SXa1Bt8lSDs1N8iVXvBFIcKtCEpZ1mmI4 (127.0.0.1): Twitter auth failed
2012-06-18 16:56:20,465 - root - ERROR - 500 GET /auth/twitter?oauth_token=Nbed9YQseoNC3YjdFkbOPS5An7OhfewcEgp3oPuq4&oauth_verifier=uGWWoItQ7SXa1Bt8lSDs1N8iVXvBFIcKtCEpZ1mmI4 (127.0.0.1) 12.96ms
谁能帮我?