Download a file from google drive using wget

First, click the share button in the top right corner, and set the permission to allow anyone with the link can view.

Click File->Download as-> PDF Document(.pdf) in the left cornel, and start to download by browser.

Find the URL in downloader, chrome is in chrome://downloads/.

The URL link by the time I am writing this answer is https://docs.google.com/document/export?format=pdf&id=xxx&token=xxx&includes_info_params=true

I was able to download as pdf with wget by wget -O xxx.pdf "https://docs.google.com/document/export?format=pdf&id=xxx"


The shortest way I have found for downloading big files:

git clone https://github.com/chentinghao/download_google_drive.git
cd download_google_drive/
python download_gdrive.py FILE_ID DESTINATION_PATH

Just view access, FILE_ID and DESTINATION_PATH (including file name) are required. It's working now as of November/12/2019 and has been for more than a year.

Another solution is googleapiclient. It enables you to automate downloading/uploading private files having their ids.

Note: Also make sure that file is publicly shared not with a group or within an organization


Insert your file ID into this URL (https://drive.google.com/uc?export=download&id=), then surround the URL with quotes so that Bash doesn't misinterpret the &, like so:

wget "https://drive.google.com/uc?export=download&id=0Bz7KyqmuGsilT0J5dmRCM0ROVHc"

Reference here.


When downloading big files, Google Drive adds a security warning that breaks the script above. In that case, you can download the file using:

wget --load-cookies /tmp/cookies.txt "https://docs.google.com/uc?export=download&confirm=$(wget --quiet --save-cookies /tmp/cookies.txt --keep-session-cookies --no-check-certificate 'https://docs.google.com/uc?export=download&id=FILEID' -O- | sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/\1\n/p')&id=FILEID" -O FILENAME && rm -rf /tmp/cookies.txt

(Script taken from here)