簡體   English   中英

詳細信息:未提供身份驗證憑據

[英]details:Authentication credentials were not provided

我能夠對我的用戶進行身份驗證以獲得令牌,但是當我嘗試查看所有用戶時,出現錯誤{"detail":"Authentication credentials were not provided."} 我看過其他相關問題和解決方案,但仍然無法正常工作。 我沒有正確地解決此問題以查看我的所有用戶而沒有得到此錯誤的正確方法

設置

REST_FRAMEWORK = { 
    'DEFAULT_AUTHENTICATION_CLASSES': (
        'rest_framework.authentication.TokenAuthentication',
    ),
    'DEFAULT_PERMISSION_CLASSES': (
        'rest_framework.permissions.IsAuthenticated',
    )
}

views.py

class UserList(generics.ListCreateAPIView):
    queryset = User.objects.all()
    serializer_class = UserSerializer

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

郵遞員形象 在此處輸入圖片說明

更新您的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'

    )
}

讓我知道,如果有幫助!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM