【问题标题】:Using tornado.auth.TwitterMixin with a callback URL?使用带有回调 URL 的 tornado.auth.TwitterMixin?
【发布时间】:2011-02-21 07:11:16
【问题描述】:

我正在尝试使用带有回调 url 的 tornado.auth.TwitterMixin,但是 我遇到了问题。 我不确定如何在 Tornado 中设置回调 url 应用。 这是我的 tornado.auth.TwitterMixin 课程:

class TAuthBindingHandler(BaseHandler,tornado.auth.TwitterMixin): 
    @tornado.web.asynchronous 
    def get(self): 
        if self.get_argument("oauth_token", None): 
self.get_authenticated_user(self.async_callback(self._on_auth)) 
            return 
        self.authorize_redirect() 
    def _on_auth(self, user): 
        if not user: 
            raise tornado.web.HTTPError(500, "Twitter auth failed") 
        tuser = self.db.get("SELECT * FROM twitterusers WHERE tid = 
%s",user["id"]) 
        bigU = self.get_current_user() 
        bigU_id = bigU['id'] 
        if not tuser: 
            any_tuser = self.db.get("SELECT * FROM twitterusers LIMIT 
1") 
            if not any_tuser: 
                tuser_id = self.db.execute( 
                    "INSERT INTO twitterusers (name,tid,user_id) 
VALUES (%s,%s,%s)", 
                    user["name"], user["id"], bigU_id) 
            else: 
                self.redirect("/") 
                return 
        else: 
            pass 
        self.redirect(self.get_argument("next", "/"))

我的问题是,我在哪里设置回调网址?我如何设置它 这节课?

我使用的是 Tornado 1.1,我的 Twitter 应用设置中没有设置任何回调。

我正在本地主机上测试它。

最好的问候。

【问题讨论】:

    标签: python twitter tornado


    【解决方案1】:

    嘿,我不确定你是否还需要答案,但self.authorize_redirect 需要callback_uri。所以在你的情况下,我会写self.authorize_redirect('http://localhost:8888/authentication-complete')。我花了一段时间才弄清楚。祝你好运!

    【讨论】:

      猜你喜欢
      • 2018-03-23
      • 1970-01-01
      • 2023-03-13
      • 1970-01-01
      • 2020-05-26
      • 2016-01-02
      • 2013-05-30
      • 2013-12-21
      • 1970-01-01
      相关资源
      最近更新 更多