Reputation: 1755
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
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
Reputation: 11
You need to include the Authorization Token with your POST request to the logout URL.
Upvotes: 1
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