def resolve(self, authorization: http.Header):
        """
        Determine the user associated with a request, using Token Authentication.
        """
        from django_apistar.authentication.models import Token

        if authorization is None:
            return None

        scheme, token = authorization.split()
        if scheme.lower() != 'bearer':
            return None

        try:
            user = Token.objects.get(key=token).user
        except Token.DoesNotExist:
            return None

        return user
def resolve ( self , authorization : http . Header ) : from django_apistar . authentication . models import Token if authorization is None : return None scheme , token = authorization . split ( ) if scheme . lower ( ) != 'bearer' : return None try : user = Token . objects . get ( key = token ) . user except Token . DoesNotExist : return None return user
Determine the user associated with a request, using Token Authentication.