我正在尝试遵循有关 Django OAuth 工具包的教程:https ://django-oauth-toolkit.readthedocs.io/en/latest/tutorial/tutorial_03.html 。说明说要更新 deMIDDLEWARE
如下:
MIDDLEWARE = (
'...',
# If you use SessionAuthenticationMiddleware, be sure it appears before OAuth2TokenMiddleware.
# SessionAuthenticationMiddleware is NOT required for using django-oauth-toolkit.
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'oauth2_provider.middleware.OAuth2TokenMiddleware',
'...',
)
但是,在我当前使用startproject
Django 2.0.1 生成的项目中,我看到了SessionMiddleware
and AuthenticationMiddleware
,但没有看到SessionAuthenticationMiddleware
:
MIDDLEWARE = [
'corsheaders.middleware.CorsMiddleware',
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
# 'oauth2_provider.middleware.OAuth2TokenMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
我应该把它放在哪里OAuth2TokenMiddleware
?在AuthenticationMiddleware
注释掉的行之后?