无法为 API 设置 'DEFAULT_AUTHENTICATION_CLASSES' 导入 'oauth2_provider.ext.rest_framework.OAuth2Authentication'
Could not import 'oauth2_provider.ext.rest_framework.OAuth2Authentication' for API setting 'DEFAULT_AUTHENTICATION_CLASSES'
这是我第一次使用 django rest 和 Django Oauth 工具包
我正在关注本教程
oauth2-with-django-rest-framework
但是当我 运行 python manage.py 迁移时,我收到以下错误:
ImportError:无法为 API 设置 'DEFAULT_AUTHENTICATION_CLASSES' 导入 'oauth2_provider.ext.rest_framework.OAuth2Authentication'。导入错误:没有名为 ext.rest_framework.
的模块
出了什么问题?我应该安装另一个模块吗?
我的虚拟环境包含:
证书==2017.4.17
chardet==3.0.4
Django==1.11.2
django-extensions==1.8.1
django-oauth-toolkit==1.0.0
djangorestframework==3.6.3
idna==2.5
oauthlib==2.0.2
pytz==2017.2
请求==2.18.1
6==1.10.0
Unidecode==0.4.21
urllib3==1.21.1
看起来像 oath2_provider.ext
has been moved 到 oauth_provider.contrib
。您可以尝试安装旧版本的 django-oauth-toolkit
,或尝试将 DEFAULT_AUTHENTICATION_CLASSES
中的值从:
更改为
'oauth2_provider.ext.rest_framework.OAuth2Authentication',
至:
'oauth2_provider.contrib.rest_framework.OAuth2Authentication',
请注意,该教程已有几年历史,您可能会发现其他类似问题。
我遇到了同样的问题。在我的设置文件中 DEFAULT_AUTHENTICATION_CLASSES 已经
'oauth2_provider.contrib.rest_framework.OAuth2Authentication',
我刚刚按照@Alasdair 的要求安装了旧版本。我的问题解决了。谢谢
这是我第一次使用 django rest 和 Django Oauth 工具包 我正在关注本教程 oauth2-with-django-rest-framework 但是当我 运行 python manage.py 迁移时,我收到以下错误:
ImportError:无法为 API 设置 'DEFAULT_AUTHENTICATION_CLASSES' 导入 'oauth2_provider.ext.rest_framework.OAuth2Authentication'。导入错误:没有名为 ext.rest_framework.
的模块出了什么问题?我应该安装另一个模块吗? 我的虚拟环境包含:
证书==2017.4.17
chardet==3.0.4
Django==1.11.2
django-extensions==1.8.1
django-oauth-toolkit==1.0.0
djangorestframework==3.6.3
idna==2.5
oauthlib==2.0.2
pytz==2017.2
请求==2.18.1
6==1.10.0
Unidecode==0.4.21
urllib3==1.21.1
看起来像 oath2_provider.ext
has been moved 到 oauth_provider.contrib
。您可以尝试安装旧版本的 django-oauth-toolkit
,或尝试将 DEFAULT_AUTHENTICATION_CLASSES
中的值从:
'oauth2_provider.ext.rest_framework.OAuth2Authentication',
至:
'oauth2_provider.contrib.rest_framework.OAuth2Authentication',
请注意,该教程已有几年历史,您可能会发现其他类似问题。
我遇到了同样的问题。在我的设置文件中 DEFAULT_AUTHENTICATION_CLASSES 已经 'oauth2_provider.contrib.rest_framework.OAuth2Authentication',
我刚刚按照@Alasdair 的要求安装了旧版本。我的问题解决了。谢谢