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