Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>After having spent several hours trying to figure out why a simple link on my app page would bring up the dreaded message "400 Bad Request - Missing signed_request." I came across this post and I finally began solving the riddle.</p> <p><a href="https://stackoverflow.com/questions/9811509/slow-load-facebook-canvas-app-when-click-on-links-if-target-top">Slow load facebook canvas app when click on links (if target top)</a></p> <p>In brief: YOU DO NOT NEED to use any decorator (e.g. @canvas_only or @facebook_required) on your view. Instead, as suggested, save the info in the session the very first time you get hold of that information (say FB user id and name). I do it in my homepage (the only view decorated with @canvas_only). Nota Bene: in order to be able to store something in the session, you need to enable it in your settings.py: it should be OK in the MIDDLEWARE section already, but also add it in the INSTALLED_APPS by uncommenting the entry 'django.contrib.sessions'.<br> Now perform a syncdb (python manage.py syncdb) to make sure the relevant tables are created (I assume the session is stored in the db). If you need it for further calls to the FB API, also store the access_token in the session (request.session ['signed_request'] = access_token)</p> <p>What really causes the problem though, is redirecting to a page at the end of the view, for ex. with redirect() or with HttpResponseRedirect(). That triggers a GET request and not a POST.<br> Oh btw, did I mention all the GET requests become POSTS? HAHAHAH it gets confusing hey? Furthermore, there are some serious security implications to be considered.</p> <p>I have just started playing with this stuff myself, so please do take the present info as hints and clues and not as commandments.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload