In this tutorial, I will share How to Download a File in Google Drive using Command Line Interface, using this script you can download a file without file size limitation, maybe you can use gdown but gdown sometimes still error if you download a big file from Google Drive
Before Download a Big File, Create OAuth Authentication First
This script also same if you don’t configure first, can’t download a big file from Google Drive, so you must create OAuth Credentials first
- Login to Google Developer Console and Create Project first
- Note: If you don’t have project Click on Select Project → New Project
- Click Hamburger menu on the left → Select API & Services → Select Library
- Search for Google Drive API and Enable Google Drive API
- Click Credentials on left pane and Click + CREATE CREDENTIALS and select OAuth Client ID
Note: If you face this error, click on CONFIGURE CONSENT SCREEN
- Select External and click CREATE
- Just fill in the section
- App name *
- User support email
- Email addresses
- Click SAVE AND CONTINUE until Step 4 and Click Publish in the Production section
- Back to Create Credentials
- After select OAuth Client ID
- Application type select Desktop app
- Name fill whatever you want
- Click CREATE
- If success, you will get Client ID and Client Secret, Save it.
Download a File From Google Drive
- This script you can find it in Official GitHub Repository
- To install this script, just execute command
curl -Ls --compressed https://drivedl.cf | sh -s
alternatively, you can use the original github url instead of https://drivedl.cf
curl -Ls --compressed https://github.com/Akianonymus/gdrive-downloader/raw/master/install.sh | sh -s
- This script installed at
${HOME}/.gdrive-downloader/
- To Download a File from Google Drive (Especially big file) use command
gdl -o driveID
- And you will be asked to put (Only one time), and this config file saved in
${HOME}/.gdl.conf
- Client ID → Fill in the client ID with the one you created earlier
- Client Secret → Fill in the client Secret with the one you created earlier
- Refresh Token → Just blank and hit enter
- And the link will appear, click on that link to get authorization code
- Login with your Google Account
- In this case Warning like this is normal, because app we create earlier is not verified by Google, so just click show advanced and click Go to yourappname (unsafe)
- Click Allow
- Click Allow Again
- And you get authorization code copy and paste to terminal console
- And file will be downloaded immediately
If you want to download a big file again, just use command gdl -o driveID
and will not be asked to enter the auth code.
For Documentation, you can see in GitHub Repository
Special Thanks to: Akianonymus for making a great script!