I am getting ModuleNotFoundError: No module named 'oauth2_provider', I have already installed
django-oauth-toolkit==1.0.0 on my requirements.txt file:
appdirs==1.4.3
certifi==2017.4.17
chardet==3.0.4
Django==1.11.1
django-cors-middleware==1.3.1
django-oauth-toolkit==1.0.0
djangorestframework==3.6.3
gunicorn==19.7.1
httpie==0.9.9
idna==2.5
oauthlib==2.0.2
packaging==16.8
psycopg2==2.7.1
Pygments==2.2.0
pyparsing==2.2.0
pytz==2017.2
requests==2.18.1
six==1.10.0
urllib3==1.21.1
My settings file:
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'restaurants.apps.RestaurantsConfig',
'rest_framework',
'rest_framework.authtoken',
'oauth2_provider',
]
'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework.authentication.TokenAuthentication',
'rest_framework.authentication.SessionAuthentication',
'oauth2_provider.ext.rest_framework.OAuth2Authentication',
),
Sounds like you might have an outdated setuptools. Try pip install --upgrade pip setuptools wheel before you install oauth2_provider. You may need to recreate your venv.
On your DEFAULT_AUTHENTICATION_CLASSES change 'oauth2_provider.ext.rest...' to 'oauth2_provider.contrib.rest...'
Right, that'll have to change as well, but it's not the source of that error I believe.
@jleclanche I did what you said and it worked, thanks a lot!, I also had to recreate the virtualenv
on my side pip was already up2date, but the @Seik 's tips worked.
Does the doc have to been fixed to tell us
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': (
'oauth2_provider.contrib.rest_framework.OAuth2Authentication',
)
}
instead of
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': (
'oauth2_provider.ext.rest_framework.OAuth2Authentication',
)
}
?
edit : in fact is already done :) https://github.com/evonove/django-oauth-toolkit/commit/cdc00603e738fdf78a217754196113cadc000f4f
Most helpful comment
On your
DEFAULT_AUTHENTICATION_CLASSESchange'oauth2_provider.ext.rest...'to'oauth2_provider.contrib.rest...'