Skip to content

Instantly share code, notes, and snippets.

@lepture
Created October 2, 2010 03:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lepture/607236 to your computer and use it in GitHub Desktop.
Save lepture/607236 to your computer and use it in GitHub Desktop.
import pydouban
@route('/login')
class Login(WebHandler):
def get(self):
auth = pydouban.Auth(key, secret) # your consumer key and secret
dic = auth.login('http://localhost/auth')
memcache.set('douban', dic)
return self.redirect(dic['url'])
@route('/auth')
class Auth(WebHandler):
def get(self):
auth = pydouban.Auth(key, secret)
dic = memcache.get('douban')
qs = auth.get_acs_token(dic['oauth_token'],dic['oauth_token_secret'])
db.Douban.set('qs', qs)
return self.response('Get access token ' + qs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment