I am using token authentication
for my current project but I have one problem, I can not authenticate a use for the life of me. To test my authentication I created a superuser
and then the command python manage.py drf_create_token test1
. And then created this view:
class HelloView(APIView):
permission_classes = (IsAuthenticated)
def get(self, request):
content = {'message': 'Hello, World!'}
return Response(content)
In my setting.py file
I have:
INSTALLED_APPS = [
... # ...
'rest_framework',
'rest_framework.authtoken',
'backend',
'frontend'
]
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': [
'rest_framework.authentication.TokenAuthentication',
],
}
And when I test my API I keep geting:
{
"detail": "Authentication credentials were not provided."
}
What am I missing here? can anyone tell me? Thank you in advance.
If you use token authentication, then you must send token in all request to server in headers. So, you header request should contain the following entry: