djangoauthenticationdjango-rest-frameworkdj-rest-auth

dj-rest-auth with JWT (problem with login functionality)


I have problem with login functionality, when the first time I log in it returns csrf_token, access_token and refresh_token . and it works fine till the expiration time. I know when the access token is expired I should get new one through refresh token but it should also work when I directly use the login route and giving username and password but I get error:

{
    "detail": "Given token not valid for any token type",
    "code": "token_not_valid",
    "messages": [
        {
            "token_class": "AccessToken",
            "token_type": "access",
            "message": "Token is invalid or expired"
        }
    ]
}

and when I see the cookies part the previous values are still there shouldn't they be vanished? I think the problem origins from here. when i manually delete them it works fine.

and even when the refresh token expires I get the same error, how does it work?


Solution

  • the solution is either go to the loginview of the source code and add the following code:

    authentication_classes = []
    

    or create your own login (inherit from the source code) and add the above code.