import base64


def get_client_id_and_secret(authorization):
    """
    Get the client ID and secret.

    Args:
        authorization (str): The authorization header.

    Returns:
        str: The client ID.
        str: The client secret.
        str: The error message.
    """
    if authorization is None:
        return None, None, "Authorization header not found."
    if " " not in authorization:
        return None, None, "Authorization header format error."
    if authorization.split(" ")[0] != "Basic":
        return None, None, "Authorization header format error."
    try:
        client_id_and_secret = base64.b64decode(authorization.split(" ")[1]).decode(
            "utf-8"
        )
    except Exception as e:
        return None, None, e.__str__()
    if ":" not in client_id_and_secret:
        return None, None, "Authorization header format error."
    client_id_and_secret_list = client_id_and_secret.split(":")
    if client_id_and_secret_list[1] == "":
        return client_id_and_secret_list[0], None, None
    return client_id_and_secret_list[0], client_id_and_secret_list[1], None