I'm trying to rename the Rest_framework TokenAuthentication keyword from "Token" to "Bearer" as suggested in the Documentation I have subclassed the TokenAuthentication class like this:
in module: user/authentication.py
from rest_framework import authentication
class TokenAuthentication(authentication.TokenAuthentication):
"""
Simple token based authentication.
Clients should authenticate by passing the token key in the "Authorization"
HTTP header, prepended with the string "Token ". For example:
Authorization: Token 401f7ac837da42b97f613d789819ff93537bee6a
"""
keyword = 'Bearer'
in module app/settings.py
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': (
'user.authentication.TokenAuthentication',
),
}
It is still sending me a 401 Unauthorized when im using 'Authorization: Bearer ...token...' but not with 'Authorization: Token ...token...'
What am I doing wrong ?
You are missing one last step. Import your TokenAuthentication
class that contains the new keyword in your View
class instead of the default TokenAuthentication
class.