Created
April 30, 2015 14:02
-
-
Save bartdag/4cfee391ebd0b6daee74 to your computer and use it in GitHub Desktop.
Django REST Framework Token Authorization through get parameter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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