import requests


def download_file_from_google_drive(file_id: str) -> bytes:
    """Custom function from rkornmeyer for pulling csv from google drive

    Parameters
    ----------
    file_id : str
        File id to pull from google drive

    Returns
    -------
    bytes
        Content from request response
    """

    def get_confirm_token(response):
        for key, value in response.cookies.items():
            if key.startswith("download_warning"):
                return value

        return None

    URL = "https://docs.google.com/uc?export=download"

    session = requests.Session()

    response = session.get(URL, params={"id": file_id}, stream=True)
    token = get_confirm_token(response)

    if token:
        params = {"id": file_id, "confirm": token}
        response = session.get(URL, params=params, stream=True)

    return response.content