Problem in logging out in Postman while sending POST Request through API

I am using POSTMAN to send API Requests.I have been logged in through API and got a token. When I try to log out using that particular token it display output as "not logged in" This is the screenshot of my token I got in Postman: token and this is the output I get while sending POST request to log out: logging out

I am trying to logout with the same token I logged in with in Django application. Here is my code in Django:

def logout_user(request):
    if request.user.is_authenticated:
        request.user.auth_token.delete()
        return Response({'message': 'Successfully logged out'})
    else:
        return Response({'error': 'Not logged in'}, status=status.HTTP_401_UNAUTHORIZED

The issue here is with your Authorization . You are passing Authorization as query param. It should be passed as header. In Authorization tab, select Bearer Token as Auth Type and paste your token in Token field.

Вернуться на верх