Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
class TokenAuthentication(BaseAuthentication):
model = djangorestframework.tokenauth.models.Token
def authenticate(self, request):
key = request.META.get('HTTP_AUTHORIZATION', '').strip()
if not key:
return None
token = self.model.objects.get(key=key)
return None
if token.user.is_active and not token.revoked:
return (token.user, token)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.