Skip to content
This repository has been archived by the owner on May 26, 2020. It is now read-only.

JSONWebTokenAuthentication object has no attribute 'media_type' #466

Open
yutaroyamanaka opened this issue Jan 9, 2019 · 0 comments
Open

Comments

@yutaroyamanaka
Copy link

Hi, I tried to use 'obtain_jwt_token' , but it didn't go well.

Environment
djangorestframework==3.9.0
djangorestframework==1.11.0

This is the setting about drf-jwt

REST_FRAMEWORK = {
    'DEFAULT_PERMISSION_CLASSES': (
        'rest_framework.permissions.IsAuthenticated',
    ),
    'DEFAULT_AUTHENTICATION_CLASSES': (
        'rest_framework_jwt.authentication.JSONWebTokenAuthentication',
        'rest_framework.authentication.SessionAuthentication',
        'rest_framework.authentication.BasicAuthentication',
    ),
}
from django.urls import path
from rest_framework_jwt.vies import obtain_jwt_token

urlpatterns = [
...,
path('token-auth/', obtain_jwt_token),
]

I think it is totally the same as usage in 'django-rest-framework-jwt/docs/index.md'
Then, I tried to send http request to localhost://token-auth/

curl -X POST -d "username=admin&password=password123" http://localhost:8000/token-auth/

However, the response was 'JSONWebTokenAuthentication object has no attribute 'media_type''

So, I changed the setting as follows.

rest_framework_jwt.authentication.JSONWebTokenAuthentication → rest_framework.parsers.JSONParser

and then
The response was 'SessionAuthentication object has no attribute 'media_type''.

I don't know how to fix this situation.
I'll be glad if someone would help me.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant