jazzband / djangorestframework-simplejwt

A JSON Web Token authentication plugin for the Django REST Framework.
https://django-rest-framework-simplejwt.readthedocs.io/
MIT License
4.02k stars 663 forks source link

Refresher token is not returned. #704

Open agent-Y opened 1 year ago

agent-Y commented 1 year ago

I am trying to use it in conjunction with dj-rest-auth, but it does not return a refresh token.

this is my settings.py

    'django.contrib.auth.backends.ModelBackend',
    'allauth.account.auth_backends.AuthenticationBackend',
]

SIMPLE_JWT = {
    'ACCESS_TOKEN_LIFETIME': timedelta(minutes=60),
    'REFRESH_TOKEN_LIFETIME': timedelta(days=30),
    'ROTATE_REFRESH_TOKENS': True,
    'BLACKLIST_AFTER_ROTATION': True,
    'AUTH_HEADER_TYPES': ('Bearer', ),
}

SITE_ID = 1

REST_FRAMEWORK = {
    'DEFAULT_AUTHENTICATION_CLASSES':
    (
        "rest_framework.authentication.BasicAuthentication",
        "rest_framework.authentication.SessionAuthentication",
        'rest_framework_simplejwt.authentication.JWTAuthentication',
    ),
}

REST_AUTH_SERIALIZERS = {
    'LOGIN_SERIALIZER': 'dj_rest_auth.serializers.LoginSerializer',
    'TOKEN_SERIALIZER': 'dj_rest_auth.serializers.TokenSerializer',
    'JWT_SERIALIZER': 'dj_rest_auth.serializers.JWTSerializer',
    'USER_DETAILS_SERIALIZER': 'accounts.serializers.UserSerializer',
    'PASSWORD_RESET_SERIALIZER': 'dj_rest_auth.serializers.PasswordResetSerializer',
    'PASSWORD_RESET_CONFIRM_SERIALIZER': 'dj_rest_auth.serializers.PasswordResetConfirmSerializer',
}

REST_AUTH_REGISTER_SERIALIZERS = {
    'REGISTER_SERIALIZER': 'dj_rest_auth.serializers.RegisterSerializer',
}

REST_AUTH = {
    'USE_JWT': True,
}
LuizDMM commented 1 year ago

Same here

2ykwang commented 1 year ago

to reproduce the issue, please provide the version of Django and other dependency packages. @LuizDMM , @agent-Y

agent-Y commented 1 year ago

I found that this error occurs when using the latest version of dj-rest-auth. And downgrading dj-rest-auth now returns a refresh_token. @2ykwang @LuizDMM

CristianEchartea97 commented 9 months ago

The documentation says that to return the refresh token you have to set JWT_AUTH_HTTPONLY=False https://dj-rest-auth.readthedocs.io/en/latest/configuration.html#jwt-auth-httponly