def validate_token(token_string):
    """
    Validate the provided authentication token.

    :param token_string: Authentication token provided.
    :type token_string: ``str``

    :return: TokenDB object on success.
    :rtype: :class:`.TokenDB`
    """
    token = Token.get(token_string)

    if token.expiry <= date_utils.get_datetime_utc_now():
        # TODO: purge expired tokens
        LOG.audit('Token with id "%s" has expired.' % (token.id))
        raise exceptions.TokenExpiredError("Token has expired.")

    LOG.audit('Token with id "%s" is validated.' % (token.id))

    return token

    Validate the provided authentication token.

    :param token_string: Authentication token provided.
    :type token_string: ``str``

    :return: TokenDB object on success.
    :rtype: :class:`.TokenDB`
    
st2common/st2common/util/auth.py