jpadilla / django-rest-framework-jwt

JSON Web Token Authentication support for Django REST Framework
http://jpadilla.github.io/django-rest-framework-jwt/
MIT License
3.19k stars 649 forks source link

Unable to set JWT token in cookies with separate frontend application (React) #376

Closed sadan closed 6 years ago

sadan commented 6 years ago

I am trying to set JWT token in cookies. It's working for the django server. But my frontend is written in React. And the value is not being set in the cookies.

# in my view

if api_settings.JWT_AUTH_COOKIE:
        expiration = (datetime.utcnow() + api_settings.JWT_EXPIRATION_DELTA)
        response.set_cookie(api_settings.JWT_AUTH_COOKIE,
            response.data['access_token'],
            expires=expiration,
            httponly=True)
mapeveri commented 6 years ago

Hi, How did you solve this issue?. Thanks!

sadan commented 6 years ago

I had to set withCredentials header set to true while making requests from frontend.

mapeveri commented 6 years ago

Great! Thanks :)