Download from Google Drive using Command Line Interface (CLI)

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

  1. Login to Google Developer Console and Create Project first
    • Note: If you don’t have project Click on Select ProjectNew Project
Click to Show Image

Create Project | Create Project

  1. Click Hamburger menu on the left → Select API & ServicesSelect Library
Click to Show Image

API & Services

  1. Search for Google Drive API and Enable Google Drive API
Click to Show Image

Enable Drive API | Enable Drive API

  1. Click Credentials on left pane and Click + CREATE CREDENTIALS and select OAuth Client ID
Click to Show Image

Create Credentials | Create Credentials

Note: If you face this error, click on CONFIGURE CONSENT SCREEN

Click to Show Image

CONFIGURE CONSENT SCREEN

  • Select External and click CREATE
Click to Show Image

CONFIGURE CONSENT SCREEN

  • 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
  1. After select OAuth Client ID
    • Application type select Desktop app
    • Name fill whatever you want
    • Click CREATE
  2. If success, you will get Client ID and Client Secret, Save it.
Click to Show Image

Client ID and Secret ID

Download a File From Google Drive

  1. This script you can find it in Official GitHub Repository
  2. To install this script, just execute command
1
curl -Ls --compressed https://drivedl.cf | sh -s

alternatively, you can use the original github url instead of https://drivedl.cf

1
curl -Ls --compressed  https://github.com/Akianonymus/gdrive-downloader/raw/master/install.sh | sh -s
  1. This script installed at ${HOME}/.gdrive-downloader/
  2. To Download a File from Google Drive (Especially big file) use command
1
gdl -o driveID

Click to Show Image

Download File from Google Drive

  1. 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
      Click to Show Image

      Download File from Google Drive

      • Login with your Google Account
        Click to Show Image

        Login 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 to Show Image

        Warning

      • Click Allow
        Click to Show Image

        Allow Apps

      • Click Allow Again
        Click to Show Image

        Allow Apps

      • And you get authorization code copy and paste to terminal console
        Click to Show Image

        Auth code

  2. And file will be downloaded immediately
Click to Show Image

Download File

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!

Bantu bagikan halaman ini ke:
Built with Hugo
Theme Stack designed by Jimmy