Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It sounds like you may have two problems:</p> <p><strong>How do I actually send the CSRF token with my POST requests from Flash?</strong></p> <p>Django also accepts CSRF tokens via the header <code>X-CRSFToken</code>. <a href="https://docs.djangoproject.com/en/dev/ref/contrib/csrf/" rel="nofollow">See the docs here</a>.</p> <p>You can append headers to your request like so: </p> <pre><code>var req:URLRequest=new URLRequest(); req.url="http://somesite.com"; var header:URLRequestHeader=new URLRequestHeader("X-CSRFToken","foobar"); req.requestHeaders.push(header); </code></pre> <p><a href="http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/URLRequest.html#requestHeaders" rel="nofollow">URLRequests docs are here</a>.</p> <hr> <p><strong>How do I get the CSRF token into my Flash file in the first place?!</strong></p> <p>(Option A) Because CSRF tokens are generated on a <em>per request</em> basis (e.g., with templating a traditional HTML form, on a GET request) the simplest thing to do is to pass the CSRF token to the Flash file via a templated parameter. Something like: <code>&lt;param name="csrf_token" value="{{ my_csrf_token }}" /&gt;</code></p> <p>(Option B) It sounds like you don't want to do the parameter thing, so your final option is to build a custom Django view which has the sole functionality of delivering a CSRFToken to your Flash file. So the Flow would be your Flash file loads, your Flash makes a GET request to <code>http://mysite.com/csrf_token/</code> which simply returns a valid CSRF token, and then you can use that token to do your POST. (Note you will need to do a GET request for each POST request).</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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