def validate_api_key_and_source(api_key_in_headers, api_key_query_params):
    """
    Validate the provided API key.

    :param api_key_in_headers: API key provided via headers.
    :type api_key_in_headers: ``str``

    :param api_key_query_params: API key provided via query params.
    :type api_key_query_params: ``str``

    :return: TokenDB object on success.
    :rtype: :class:`.ApiKeyDB`
    """
    if not api_key_in_headers and not api_key_query_params:
        LOG.audit("API key is not found in header or query parameters.")
        raise exceptions.ApiKeyNotProvidedError("API key is not provided.")

    if api_key_in_headers:
        LOG.audit("API key provided in headers")

    if api_key_query_params:
        LOG.audit("API key provided in query parameters")

    return validate_api_key(api_key_in_headers or api_key_query_params)

    Validate the provided API key.

    :param api_key_in_headers: API key provided via headers.
    :type api_key_in_headers: ``str``

    :param api_key_query_params: API key provided via query params.
    :type api_key_query_params: ``str``

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