Commits

zuroc committed 01eb896

f

  • Participants
  • Parent commits 6204e3a

Comments (0)

Files changed (1)

File .app/oauth/model/douban.py

 #coding:utf-8
+import _env
+from misc.config.oauth import DOUBAN_API_KEY, DOUBAN_API_SECRET
+import tornado.auth
+
+def callback_url(self):
+    redirect_url = self.get_argument('path', None)
+    path = self.request.path
+    if redirect_url:
+        if redirect_url[0] != '/':
+            redirect_url = '/'+redirect_url
+        path = path + '?path=%s'%quote(redirect_url)
+    return path
+
+def _on_request(self, callback, response):
+    if response.error:
+        logging.warning('Error response %s fetching %s', response.error,
+                        response.request.url)
+        callback(None)
+        return
+    callback(response.body)
 
 class DoubanMixin(tornado.auth.OAuthMixin):
     _OAUTH_REQUEST_TOKEN_URL = 'http://www.douban.com/service/auth/request_token'
 
     def _oauth_consumer_token(self):
         return dict(
-            key=DOUBAN_CONSUMER_KEY,
-            secret=DOUBAN_CONSUMER_SECRET)
+            key=DOUBAN_API_KEY,
+            secret=DOUBAN_API_SECRET)
 
     def _oauth_get_user(self, access_token, callback):
         callback = self.async_callback(self._parse_user_response, callback)