Showing 1-7 of 7 messages
Shane Spencer 5/23/13 12:36 PM
I wish other people were running into these problems so that google would return the answers.

So I am using coroutines just like in the documentation for the TwitterMixIn.. infact it is direct copy/paste.

I get a response back from the Twitter OAUTH service, however self._headers_written) is set BEFORE self._on_request_token is called.. making the redirect at the end of it useless and it throws an exception of course.

I'm not entirely sure where to start diagnosing this problem... could this be because I am not yielding the authenticate_redirect/authorize_redirect or returning it directly?
Re: sh...@bogomip.com 5/23/13 1:17 PM
Apparently I failed to use a subject line.. my apologies.
Re: [tornado] Ben Darnell 5/23/13 7:31 PM
On Thu, May 23, 2013 at 3:36 PM, Shane Spencer <sh...@bogomip.com> wrote:
I wish other people were running into these problems so that google would return the answers.

So I am using coroutines just like in the documentation for the TwitterMixIn.. infact it is direct copy/paste.

I get a response back from the Twitter OAUTH service, however self._headers_written) is set BEFORE self._on_request_token is called.. making the redirect at the end of it useless and it throws an exception of course.

This is often caused by a missing @asynchronous decorator, but if you've got that the next thing to look at is what exactly were the headers that were written?  Did something generate an error, or did the request finish "successfully"?
 

I'm not entirely sure where to start diagnosing this problem... could this be because I am not yielding the authenticate_redirect/authorize_redirect or returning it directly?

No, you don't need to yield or return the authorize_redirect call.

-Ben
 

--
You received this message because you are subscribed to the Google Groups "Tornado Web Server" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python-tornad...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Re: [tornado] Shane Spencer 5/23/13 7:56 PM
Well now it's saying the request token is invalid (from Twitter) so as soon as I fix that.. I'll be able to test this.

In the mean time I moved over to OneAll for auth.. it blended right in to Tornado.  
Re: m_ob...@onet.eu 5/28/13 10:29 PM
I think I've got the same problem in this code:

#!/usr/bin/python
# -*- coding: utf-8 -*-

import logging

import tornado.httpserver
import tornado.ioloop
import tornado.options
import tornado.web
import tornado.gen
import tornado.auth

from tornado.options import define, options
define("port", default=8000, help="run on the given port", type=int)

class BaseHandler(tornado.web.RequestHandler):
    def get_current_user(self):
        return self.get_secure_cookie("user")

class MainHandler(BaseHandler, tornado.auth.TwitterMixin):
    @tornado.web.asynchronous
    @tornado.gen.coroutine
    def get(self):
        if self.get_argument("oauth_token", None):
            user = yield self.get_authenticated_user()
            if not user:
                raise tornado.web.HTTPError(500, "Twitter auth failed")
            self.set_secure_cookie("twitter_user", user)
            self.redirect("/")           
        else:
            self.authenticate_redirect()

class Application(tornado.web.Application):
    def __init__(self):
        handlers = [
            (r"/", MainHandler),
        ]
        settings = dict(
            twitter_consumer_key='RRLmRmSLfjMoJvi7qYfQ',
            twitter_consumer_secret='zgn6j0ln6eS6hvu9Ns9FELtD2uiRKwYfmXi3rfdYCfs',
            debug=True,
        )
        tornado.web.Application.__init__(self, handlers, **settings)

if __name__ == "__main__":
    tornado.options.parse_command_line()
    app = Application()
    http_server = tornado.httpserver.HTTPServer(app)
    http_server.listen(options.port)
    tornado.ioloop.IOLoop.instance().start()

It works after changing @tornado.gen.coroutine to @tornado.gen.engine.


Re: [tornado] Re: Алексей Силк 5/29/13 5:49 AM
I use old way. Still don't understand how to use in new way! If you'll handle that, please inform me ...

С уважением, Алексей Силк
With best regards, Aleksey Silk
 
+7 (981) 849-12-36
skype - rootiks
 


2013/5/29 m_ob...@onet.eu <m_ob...@onet.eu>



--
You received this message because you are subscribed to the Google Groups "Tornado Web Server" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python-tornad...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Re: [tornado] Re: Ben Darnell 5/29/13 6:20 AM
Ah, I see what's happening.  The auth*_redirect methods don't return Futures so they can't be yielded, but they should.  As a workaround for now you can continue to use @gen.engine and call these methods without yielding.

-Ben





--
You received this message because you are subscribed to the Google Groups "Tornado Web Server" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python-tornad...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.