0
我想Twitter的登錄我的應用程序集成,我寫了這個代碼OAuth的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))
,並在我的Twitter的應用程序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
誰能幫助我?
我的網站是http://restfs.beolink.org作爲應用程序網站我把相同的,因爲回調我把https://127.0.0.1/auth/twitter – fege
當你使用http:// restfs會發生什麼.beolink.org/auth/twitter作爲你的回調URI?也許閱讀這篇文章:http://www.tonyamoyal.com/2009/08/17/how-to-quickly-set-up-a-test-for-twitter-oauth-authentication-from-your-local-machine / –