Anoop K George
Anoop K George

Reputation: 1755

How logout from Djoser (installed with Django Rest Framework)

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.

Upvotes: 1

Views: 2737

Answers (3)

Daniel McKinney
Daniel McKinney

Reputation: 31

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)
 }

Upvotes: 3

Nicholas L.
Nicholas L.

Reputation: 11

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

Upvotes: 1

bhargava.prabu
bhargava.prabu

Reputation: 708

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'),

Upvotes: 1

Related Questions