0
votes

I have installed Djoser with Django Rest Framework, after loggin in as (url : /token/login ) I receive a token, but when I change url to '/token/logout/ ' it shows error as logging credential not provided.

I am using browser url section to interact with DRF.

Please advice me correct url to logout ? I can provide Token,username and password.

3

3 Answers

2
votes

I was stuck on this too. What worked for me was to pass the token as normal through the authentication header AND pass it as json data.

export const logout = (token) => {
 return url
  .post('api/auth/token/logout/', token,
   {
     headers: {
       Authorization: `Token ${token}`
     }
   })
 .then(res => res.data)
 }
1
votes

Have you something like this

#urls.py
from django.contrib.auth import views as auth_views

path('logout/', auth_views.LogoutView.as_view(), name='logout'),
1
votes

You need to include the Authorization Token with your POST request to the logout URL.