I have an application which I implemented django restframework and django reat-auth and jango framework jwt. I followed the instructions and every thing works fine in the browser. I now decided to test out the connection in postman and trying to get the logged in user's details which the endpoint is /rest-auth/user
but i get the following error
{
"detail": "Authentication credentials were not provided."
}
and I decided to copy the returned Token and put it in the header of the user url as
"Authorization": "Token ahagjbeghq7hbcvgqhvwqu08hevug.jwhhwiiwhw",
"Content-Type": "application/json; charset=utf-8"
after modifying the header with the returned token I expected it to display the user's details but instead I still got
{
"detail": "Authentication credentials were not provided."
}
but I can verify that the token is correct through the url provided by the restframework jwt
/api-token-verify
which retuns the token value back. this is my django rest authentication classes
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework_jwt.authentication.JSONWebTokenAuthentication',
'rest_framework.authentication.TokenAuthentication',
'rest_framework.authentication.BasicAuthentication',
),
'DEFAULT_PERMISSION_CLASSES': (
'rest_framework.permissions.AllowAny',
'rest_framework.permissions.IsAuthenticatedOrReadOnly',
),
}
You should use JWT
instead of Token
inside Authorization
header for jwt token:
"Authorization: JWT <your_token>"