[英]details:Authentication credentials were not provided
I am able to authenticate my users to get the token but when i try to view all my users, i get the error {"detail":"Authentication credentials were not provided."}
. 我能够对我的用户进行身份验证以获得令牌,但是当我尝试查看所有用户时,出现错误{"detail":"Authentication credentials were not provided."}
。 I have had a look at other related issues and solutions but i am still not getting it working. 我看过其他相关问题和解决方案,但仍然无法正常工作。 What am i not doing right to solve this issue to view all my users without getting this error 我没有正确地解决此问题以查看我的所有用户而没有得到此错误的正确方法
settings 设置
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework.authentication.TokenAuthentication',
),
'DEFAULT_PERMISSION_CLASSES': (
'rest_framework.permissions.IsAuthenticated',
)
}
views.py views.py
class UserList(generics.ListCreateAPIView):
queryset = User.objects.all()
serializer_class = UserSerializer
httpd.conf httpd.conf文件
Alias /bitnami/ "/Applications/XAMPP/xamppfiles/apache2/htdocs/"
Alias /bitnami "/Applications/XAMPP/xamppfiles/apache2/htdocs"
<Directory "/Applications/XAMPP/xamppfiles/apache2/htdocs">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
WSGIPassAuthorization On
update your settings.py file to support some additional rest_framework classes - 更新您的settings.py文件以支持其他一些rest_framework类-
REST_FRAMEWORK = {
'DEFAULT_PERMISSION_CLASSES': [
'rest_framework.permissions.IsAdminUser',
'rest_framework.permissions.IsAuthenticated',
],
'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework.authentication.TokenAuthentication',
'rest_framework.authentication.BasicAuthentication',
'rest_framework.authentication.SessionAuthentication'
)
}
Let me know, if it helps! 让我知道,如果有帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.