How to Use React to Authenticate to Django REST Framework

25 views Asked by At

I am trying to figure out how to authenticate to the Django REST Framework with React. I am using AXIOS. But no matter what I try, I seem to get a 403 - CSRF verification failed. Request aborted.

In Chrome, I go to DRF's default login point. I enter the username and password and click submit. It works in Chrome. In DevTools, I can see the POST. Now if I try that same POST in React, I get a 403 with the CSRF error. How is that even possible? In React I am doing the same thing that Chrome is doing. How can it produce a different result?

Here's me logging in from Chrome...

enter image description here

What am I missing?

What am I missing? I keep reading about doing a GET request, looking at the set-cookie csrf token and value, and putting that in a header on my POST request. I've tried that and every variation I can think of to no avail.

0

There are 0 answers