I am trying to implement Token based Authorization at my server APIs. But, when I fire a query then it returns {"detail": "Authentication credentials were not provided."}
I have done almost all the settings recommended at various posts and also at the Django documentation.
In my settings.py
:
INSTALLED_APPS = [
'rest_framework.authtoken',
]
And also,
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework.authentication.TokenAuthentication',
),
'DEFAULT_PERMISSION_CLASSES': (
'rest_framework.permissions.IsAuthenticated',
),
}
In my views file:
from rest_framework.authentication import TokenAuthentication
from rest_framework.permissions import IsAuthenticated
class UserList(generics.ListCreateAPIView):
queryset = User.objects.all()
serializer_class = UserSerializer
authentication_classes = [TokenAuthentication]
permission_classes = [IsAuthenticated]
And in my Apache Config file at WSGI
WSGIPassAuthorization On
RewriteEngine on
RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule .* - [e=HTTP-AUTHORIZATION:%1]
I don't know if I am missing anything other than this. The token is pre-generated at super user level using command line.