def download_file_from_google_drive(_id, destination):
def get_confirm_token(_response):<EOL><INDENT>for key, value in _response.cookies.items():<EOL><INDENT>if key.startswith('<STR_LIT>'):<EOL><INDENT>return value<EOL><DEDENT><DEDENT>return None<EOL><DEDENT>def save_response_content(_response, _destination):<EOL><INDENT>chunk_size = <NUM_LIT><EOL>with open(str(_destination), "<STR_LIT:wb>") as f:<EOL><INDENT>for chunk in _response.iter_content(chunk_size):<EOL><INDENT>if chunk:  <EOL><INDENT>f.write(chunk)<EOL><DEDENT><DEDENT><DEDENT><DEDENT>url = "<STR_LIT>"<EOL>session = requests.Session()<EOL>response = session.get(url, params={'<STR_LIT:id>': _id}, stream=True)<EOL>token = get_confirm_token(response)<EOL>if token:<EOL><INDENT>params = {'<STR_LIT:id>': _id, '<STR_LIT>': token}<EOL>response = session.get(url, params=params, stream=True)<EOL><DEDENT>save_response_content(response, destination)<EOL>
Download a file from Google Drive using it's ID

:param _id: File id on google drive
:param destination: Location to save file

This function is adapted from https://stackoverflow.com/a/39225039