V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
Tornado Documentation
http://www.v2ex.com/tornado/
Tornado on GitHub
https://github.com/facebook/tornado/
Tornado Gists
http://tornadogists.org/
gino
V2EX  ›  Tornado

请教个tornado用sina oauth2登录的问题

  •  
  •   gino · 2012-11-17 12:22:30 +08:00 · 4724 次点击
    这是一个创建于 4150 天前的主题,其中的信息可能已经有所发展或是发生改变。
    我用 https://github.com/lepture/tornado.third/blob/master/weibo.py 做登录

    怎么就死活取不到uid呢,测试下来,好像就没有请求 ACCESS_TOKEN

    希望指点下,谢谢
    2 条回复    1970-01-01 08:00:00 +08:00
    gino
        1
    gino  
    OP
       2012-11-17 12:28:55 +08:00
    class signin_sina(RequestHandler,WeiboMixin):
    @tornado.web.asynchronous
    def get(self):
    next = self.get_argument("next",None)
    state = self.get_argument("state", None)
    redirect_uri = SINA_redirect_uri

    if self.get_argument("code", False):
    self.get_authenticated_user(
    redirect_uri = redirect_uri,
    client_id = SINA_CONSUMER_KEY,
    client_secret = SINA_CONSUMER_SECRET,
    code = self.get_argument("code"),
    callback = self.async_callback(self._on_login,state))
    return
    self.authorize_redirect(
    redirect_uri = redirect_uri,
    client_id = SINA_CONSUMER_KEY,
    extra_params={"response_type": "code","state": next},
    )

    def _on_login(self, user):
    print user
    print 'uuuuu'
    self.finish()


    Handler是这样的,没有任何输出,但是登录sina是成功了
    raptium
        2
    raptium  
       2012-11-17 14:41:00 +08:00
    callback = self.async_callback(self._on_login,state))

    所以你的 user 就是 state ?
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5181 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 09:32 · PVG 17:32 · LAX 02:32 · JFK 05:32
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.