CLI for Google Drive using the official Google API Python client.
Features
- OAuth login without mandatory
gcloud pipx-friendly install (gdriveavailable globally)- List folder contents via folder ID or folder link
- Upload local files to a folder via folder ID or folder link
- Download files via file ID or file link
- Move files to trash via file ID or file link
- Diagnostics with
gdrive doctor
Install (Recommended)
python3 -m pip install --user pipx python3 -m pipx ensurepath pipx install google-drive-cli-for-agents
Verify:
Upgrade:
pipx upgrade google-drive-cli-for-agents
Install From Source
Local development:
python3 -m venv .venv source .venv/bin/activate pip install -e ".[dev]"
Install via pipx from local clone:
pipx install -e /absolute/path/to/google-drive-cli
OAuth Setup
Create a Google OAuth client of type Desktop app, then run:
gdrive auth login --client-secret /absolute/path/to/client_secret.json
Readonly token:
gdrive auth login --readonly --client-secret /absolute/path/to/client_secret.json
Inspect local credentials:
gdrive auth whoami gdrive doctor
Usage
List a folder (or root if omitted):
gdrive ls --folder https://drive.google.com/drive/folders/<folder-id> gdrive ls --folder <folder-id> gdrive ls
Upload a file:
gdrive upload ./report.csv --folder <folder-id> gdrive upload ./report.csv --folder https://drive.google.com/drive/folders/<folder-id>
Download a file:
gdrive download --file <file-id> gdrive download --file https://drive.google.com/file/d/<file-id>/view --output-path ./report.csv
Move a file to trash:
gdrive trash --file <file-id> gdrive trash --file https://drive.google.com/file/d/<file-id>/view
Output Formats
gdrive ls supports:
--output table(default)--output json--output csv --csv-path ./files.csv
gdrive upload supports:
--output table(default)--output json
Credentials Path
By default credentials are stored at:
~/.config/gdrive-cli/credentials.json
Override with env vars:
GDRIVE_CONFIG_DIRGDRIVE_CREDENTIALS_FILE
ADC Fallback (Optional)
If preferred, ADC via gcloud still works:
gcloud auth application-default login \ --client-id-file=/absolute/path/to/client_secret.json \ --scopes=https://www.googleapis.com/auth/cloud-platform,https://www.googleapis.com/auth/drive
Publishing
Build artifacts:
Upload manually:
python -m twine upload dist/*