dj-rest-auth icon indicating copy to clipboard operation
dj-rest-auth copied to clipboard

How to get the browser to store the jwt cookies?

Open ghost opened this issue 3 years ago • 4 comments

The cookies are sent in the response headers from the django server, however the browser is not storing them nor sending them in subsequent requests. For now, I’m making the subsequent requests with the header {Authorisation: Bearer }, this works but my request does not contain the JWT cookies.

Why is that? How do I set the jwt cookies so they’re stored in the browser and used in subsequent requests?

ghost avatar Nov 21 '22 07:11 ghost

Did you find answers?

iboughtbed avatar Feb 01 '23 17:02 iboughtbed

Did you add the following class to the REST_FRAMEWORK setting: 'dj_rest_auth.jwt_auth.JWTCookieAuthentication'?

Example:

REST_FRAMEWORK = {
    'DEFAULT_AUTHENTICATION_CLASSES': (
        'dj_rest_auth.jwt_auth.JWTCookieAuthentication',
    )
    'DEFAULT_SCHEMA_CLASS': 'rest_framework.schemas.coreapi.AutoSchema'
}

rochdikhalid avatar Feb 10 '23 11:02 rochdikhalid

Did you add the following class to the REST_FRAMEWORK setting: 'dj_rest_auth.jwt_auth.JWTCookieAuthentication'?

Example:

REST_FRAMEWORK = {
    'DEFAULT_AUTHENTICATION_CLASSES': (
        'dj_rest_auth.jwt_auth.JWTCookieAuthentication',
    )
    'DEFAULT_SCHEMA_CLASS': 'rest_framework.schemas.coreapi.AutoSchema'
}

Also you should check if the frontend and backend are on the same host(localhost, 127.0.0.1)

iboughtbed avatar Feb 13 '23 05:02 iboughtbed

Hi,

I think there is a problem on how the JWT cookies authentication is set which I reported on the Issue #584 . Also, it seems like there is the need of a new attribute for "Partitioned" when SAMESITE is none.

I hope this helps.

Parbelaez avatar Apr 22 '24 16:04 Parbelaez