(self, token)
Due to the random nature of hashing a value, this must inspect
        each auth_token individually to find the correct one.

        Tokens that have expired will be deleted and skipped
Due to the random nature of hashing a value, this must inspect
        each auth_token individually to find the correct one.
Due to the random nature of hashing a value this must inspect each auth_token individually to find the correct one .
def authenticate_credentials(self, token):
        '''
        Due to the random nature of hashing a value, this must inspect
        each auth_token individually to find the correct one.

        Tokens that have expired will be deleted and skipped
        '''
        msg = _('Invalid token.')
        token = token.decode("utf-8")
        for auth_token in AuthToken.objects.filter(
                token_key=token[:CONSTANTS.TOKEN_KEY_LENGTH]):
            if self._cleanup_token(auth_token):
                continue

            try:
                digest = hash_token(token)
            except (TypeError, binascii.Error):
                raise exceptions.AuthenticationFailed(msg)
            if compare_digest(digest, auth_token.digest):
                if knox_settings.AUTO_REFRESH and auth_token.expiry:
                    self.renew_token(auth_token)
                return self.validate_user(auth_token)
        raise exceptions.AuthenticationFailed(msg)
def authenticate_credentials ( self , token ) : msg = _ ( 'Invalid token.' ) token = token . decode ( "utf-8" ) for auth_token in AuthToken . objects . filter ( token_key = token [ : CONSTANTS . TOKEN_KEY_LENGTH ] ) : if self . _cleanup_token ( auth_token ) : continue try : digest = hash_token ( token ) except ( TypeError , binascii . Error ) : raise exceptions . AuthenticationFailed ( msg ) if compare_digest ( digest , auth_token . digest ) : if knox_settings . AUTO_REFRESH and auth_token . expiry : self . renew_token ( auth_token ) return self . validate_user ( auth_token ) raise exceptions . AuthenticationFailed ( msg )