I have recently deployed a REST API for a user authentication and authorization system using Django and Django REST Framework. The system should support user registration, authentication, token refresh, logout, and allow users to retrieve and update their personal information.
I have done everything, but one thing remains: the user logout:
`Endpoint: /api/logout/
Method: POST
Body: {“refresh_token”: “eb0464c2-ed6e-4346-a709-042c33946154”}
Response: {“success”: “User logged out.”}
curl -X POST http://localhost:8000/api/logout/ -d ‘{“refresh_token”: “eb0464c2-ed6e-4346-a709-042c33946154”}’ -H “Content-Type: application/json”
I have written the code for logout, it’s on github: https://github.com/AnakinSolo1983/RESTful-API-for-User-Authentication.git.`
So, after I have deployed the app, I have made the following discovery: no matter which browser you’re using, a user cannot access logout page unless he’s registered on admin. The logout page shows the message “Authentication Credentials Not Provided” as shown in the caption below:
enter image description here
But if I login on to admin and try to logout a user that I have created, it works:
enter image description here
The code on GitHub is public, so be free to take a look at it. If there is somehow to fix this problem, and you know the solution, please let me know, thank you.
I tried to add AllowAny to the permission classes, still did not work.