Skip to content

Instantly share code, notes, and snippets.

@bartdag
Created April 30, 2015 14:02
Show Gist options
  • Save bartdag/4cfee391ebd0b6daee74 to your computer and use it in GitHub Desktop.
Save bartdag/4cfee391ebd0b6daee74 to your computer and use it in GitHub Desktop.
Django REST Framework Token Authorization through get parameter
from rest_framework import authentication
from rest_framework import exceptions
class TokenParameterAuthentication(authentication.TokenAuthentication):
def authenticate(self, request):
token = request.GET.get('token')
if token == "":
msg = "Invalid token parameter. No credentials provided."
raise exceptions.AuthenticationFailed(msg)
elif not token:
return None
return self.authenticate_credentials(token)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment