Skip to content
Advertisement

How to send JWT REFRESH TOKEN as http only cookie in django?

I am using Django(REST FrameWork, SimpleJWT) and React for my project. For autentication I am using JWT method.

According to some articles, storing and sending REFRESH TOKEN in HttpOnly Cookie is the a best and secure way. Since I am learning WebDevelopment I can’t able to find any source to about it.

This is my views.py

JavaScript

as you can i even tried to over write the post method in MyTokenObtainPairView.

This is my urls.py

JavaScript

This is my settings.py

JavaScript

I am expecting a way to store and send REFRESH TOKEN in HttpOnly Cookie to frontend when user logins or refresh it.

Advertisement

Answer

You might find an answer in this thread:
How to store JWT tokens in HttpOnly cookies with DRF djangorestframework-simplejwt package?

This GitHub comment also suggests a similar solution.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement