Friday, September 22, 2017

CSRF and API Calls

I'm having a bit of an issue. I'm attempting to utilize a Javascript/React App to interact with a Django backend without the use of templates (hence no {%csrftoken%} available). As I understand CSRF middleware, the CSRF token comes with the form on the GET and is provided in the POST; however, if I'm not utilizing the templates and the app is completely separate from Django. 

How do I go about obtaining the CSRF token prior to making the POST/PUT/etc.?

Let me know if you need more context. Appreciate any assistance!

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/13ecce96-2de8-4a42-8b1e-3b98ccbae524%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment