更新时间:2023-11-30 23:24:46
默认情况下,Django Rest Framework有两个身份验证类,请参阅这里。
By default, Django Rest Framework has two authentication classes, see here.
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework.authentication.SessionAuthentication',
'rest_framework.authentication.BasicAuthentication'
)}
您可以禁用其余框架如果你不需要认证。
You can disable the rest framework authentication if you don't need it.
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': ()
}
或者您只能删除 BasicAuthentication
,因为它将适用于您的案例。 (
'rest_framework.authentication.SessionAuthentication'
)
Or you can remove only BasicAuthentication
as it will work in your case.
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework.authentication.SessionAuthentication'
)}