def default_token_validator(self, user_id, token, token_ts=None):
    'Validates a token.\n\n        Tokens are random strings used to authenticate temporarily. They are\n        used to validate sessions or service requests.\n\n        :param user_id:\n            User id.\n        :param token:\n            Token to be checked.\n        :param token_ts:\n            Optional token timestamp used to pre-validate the token age.\n        :returns:\n            A tuple ``(user_dict, token)``.\n        '
    now = int(time.time())
    delete = (token_ts and ((now - token_ts) > self.config['token_max_age']))
    create = False
    if (not delete):
        (user, ts) = self.get_user_by_auth_token(user_id, token)
        if user:
            delete = ((now - ts) > self.config['token_max_age'])
            create = ((now - ts) > self.config['token_new_age'])
    if (delete or create or (not user)):
        if (delete or create):
            self.delete_auth_token(user_id, token)
            if delete:
                user = None
        token = None
    return (user, token)
Validates a token.

Tokens are random strings used to authenticate temporarily. They are
used to validate sessions or service requests.

:param user_id:
    User id.
:param token:
    Token to be checked.
:param token_ts:
    Optional token timestamp used to pre-validate the token age.
:returns:
    A tuple ``(user_dict, token)``.
def default_token_validator(self, user_id, token, token_ts=None):
    'Validates a token.\n\n        Tokens are random strings used to authenticate temporarily. They are\n        used to validate sessions or service requests.\n\n        :param user_id:\n            User id.\n        :param token:\n            Token to be checked.\n        :param token_ts:\n            Optional token timestamp used to pre-validate the token age.\n        :returns:\n            A tuple ``(user_dict, token)``.\n        '
    now = int(time.time())
    delete = (token_ts and ((now - token_ts) > self.config['token_max_age']))
    create = False
    if (not delete):
        (user, ts) = self.get_user_by_auth_token(user_id, token)
        if user:
            delete = ((now - ts) > self.config['token_max_age'])
            create = ((now - ts) > self.config['token_new_age'])
    if (delete or create or (not user)):
        if (delete or create):
            self.delete_auth_token(user_id, token)
            if delete:
                user = None
        token = None
    return (user, token)