未提供 Django Rest Framework allauth 身份验证凭据

Django Rest Framework allauth Authentication credentials were not provided

我正在使用 django allauth 进行身份验证

这是我的settings.py

REST_FRAMEWORK = {
    'DEFAULT_AUTHENTICATION_CLASSES': [
        'rest_framework.authentication.TokenAuthentication',
        'rest_framework.authentication.SessionAuthentication',
    ],
    'DEFAULT_PERMISSION_CLASSES': [
        'rest_framework.permissions.IsAuthenticated'
    ],
}

安装的应用是这些:

'rest_framework',
'rest_framework.authtoken',
'rest_auth',
'rest_auth.registration',
'allauth',
'allauth.account',

我正在尝试这样的方式:

curl -X POST "http://127.0.0.1:8000/api/v1/cinema-hall/" -H 'Authorization: Token 44eba1cdb1ecde6d3a55d6c85d7c4f44315f2c44'

我收到这个错误:

{"detail":"Authentication credentials were not provided."}

我看到很多类似的 post 存在这样的:Django Rest Framework Authentication credentials were not provided

但这些都没有解决我的问题。

谁能告诉我出现这个错误的可能原因是什么?

我对使用 CURL 测试 api 不是很有经验,但是 'Authorization' 是否有可能被拼错为 'Authorizaion'?

编辑:在您的回复确认情况并非如此后,我注意到您在默认身份验证中同时拥有 TokenAuthentication 和 SessionAuthentication 类。删除 SessionAuthentication 或添加所需的凭据(包含会话详细信息和 csrf 令牌的 cookie)。