Facebook Canvas App - Circular Login Redirect

83 views
Skip to first unread message

Jeff G

unread,
Jun 3, 2012, 2:59:24 PM6/3/12
to python-...@googlegroups.com

Hey Tornado team - I'm using the Tornado based Social Cookbook template to create a Facebook App, but I'm having a problem with Canvas support which does a POST instead of a GET. The example doesn't include how to handle this. Based on reading and looking at the Run With Friends example, I'm able to get the signed request, read the data (user id, token), and set the method to GET.

However, as it continues, the Browser / Tornado Server go into a loop where it repeatedly runs the LoginHandler. Giving me an error "Firefox has detected that the server is redirecting the request for this address in a way that will never complete." I've been trying to figure this out for two days. Thanks for any guidance you could provide in modifying the Social Cookbook to support the Facebook Canvas!

Here is what I had done so far...

class BaseHandler(tornado.web.RequestHandler):

    def initialize(self):
        self.init_facebook()
           
    def init_facebook(self):
        # initial facebook request comes in as a POST with a signed_request
        signed_request = self.get_argument('signed_request', None)
        if signed_request and self.request.method == u'POST':
            app_secret = options.facebook_app_secret
            data = load_signed_request(signed_request, app_secret)
            user_id = data.get(u"user_id")
            mytoken = data.get(u"oauth_token")
            print mytoken
            self.set_secure_cookie("uid", user_id)
            self.request.method = u'GET'  # causes loss of request.POST data

Jeff G

unread,
Jun 6, 2012, 2:49:21 PM6/6/12
to python-...@googlegroups.com
I posted the code to what we did to get this working at Stack Overflow if anyone is interested.  http://stackoverflow.com/questions/10865851/facebook-canvas-app-circular-login-redirect/10920183#10920183
Reply all
Reply to author
Forward
0 new messages