django-rest-framework-jwt
django-rest-framework-jwt copied to clipboard
Issue with importing JWT for Authentication after following the tutorial
I'm getting the following error after following the tutorial. It's worth noting that I am only getting this error in heroku and not local.
ImportError: Could not import 'rest_framework_jwt.authentication.JSONWebTokenAuthentication' for API setting 'DEFAULT_AUTHENTICATION_CLASSES'. ImportError: No module named rest_framework_jwt.authentication.
The error appears to be with importing in here:
REST_FRAMEWORK = {
'DEFAULT_PERMISSION_CLASSES': (
'rest_framework.permissions.IsAuthenticated',
),
'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework.authentication.SessionAuthentication',
'rest_framework.authentication.BasicAuthentication',
'rest_framework_jwt.authentication.JSONWebTokenAuthentication',
),
}
It's in the requirements.txt:
dj-static==0.0.6
Django==1.9.2
django-cors-headers==1.1.0
djangorestframework==3.3.3
djangorestframework-jwt==1.8.0
PyJWT==1.4.1
static3==0.7.0
Any help will be really appreciated.
Thanks in advance.
In the INSTALL_APPS
, make sure you included 'auth_jwt" entry.
@whippersnapper adding 'auth_jwt' does not solve the problem. Does anyone know what module to add to installed apps so that 'rest_framework_jwt' becomes available? Thanks
In my case the problem was I had the wrong virtualenv activated. For rest_framework_jwt to be available, all you need to do is pip install djangorestframework-jwt into your virtual environment. Your interpreter will find it just fine.
None of the above solutions works for me. Any other ideas?
Try adding 'DEFAULT_PERMISSION_CLASSES': ( 'rest_framework.permissions.AllowAny', ),
in REST_FRAMEWORK. It worked fine for me
djangorestframework-jwt is a seperate package.pip install djangorestframework-jwt should solve the problem.
I get the same issue, tried all above solutions given, nothing worked.., any help!! Thanks in advance.
I fixed it by running pipenv shell before running the server
@warlordzephyr , would please provide more descriptiin and the steps you used?