DRF and React - request.user is "Anonymous user"

401 views
Skip to first unread message

Jackson Patrick

unread,
Sep 12, 2022, 12:22:22 AM9/12/22
to django...@googlegroups.com
I have used simple JWT for authentication and i have successfully logged in and am getting tokens also. But when i do a request.user in backend i get "Annonymous user".
Tried passing Authorization header in axios post in FE REACT but it throws error. Am setting both refresh and access in a state variable and store it in local storage . Am really new into this and I'm totally stuck here.

All i did was to temporarily solve the issue is to send the user id from frontend to backend and by the way it's a bad practice.

So please help me out in this guys.

Mohammad Ehsan Ansari

unread,
Sep 20, 2022, 12:14:03 AM9/20/22
to Django users
make sure you have listed auth as jwt and added permission class for authentication 

Jackson Patrick

unread,
Sep 20, 2022, 12:19:51 AM9/20/22
to django...@googlegroups.com
Do i need to pass token in headers?

--
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...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/1f69ceeb-7294-4d51-a25c-b1a222c534d0n%40googlegroups.com.

Mohammad Ehsan Ansari

unread,
Sep 20, 2022, 1:16:47 AM9/20/22
to django...@googlegroups.com

Mohammad Ehsan Ansari

unread,
Sep 20, 2022, 1:26:13 AM9/20/22
to Django users
if you are not able to solve please connect me on mdehs...@gmail.com

Deep Chirag

unread,
Sep 20, 2022, 9:39:28 AM9/20/22
to django...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages