Skip to main content

CLI for Google Drive

Project description

google-drive-cli-for-agents

CLI for Google Drive using the official Google API Python client.

Features

  • OAuth login without mandatory gcloud
  • pipx-friendly install (gdrive available 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:

gdrive --version

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_DIR
  • GDRIVE_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:

python -m build

Upload manually:

python -m twine upload dist/*

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

google_drive_cli_for_agents-0.1.1.tar.gz (13.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

google_drive_cli_for_agents-0.1.1-py3-none-any.whl (11.1 kB view details)

Uploaded Python 3

File details

Details for the file google_drive_cli_for_agents-0.1.1.tar.gz.

File metadata

File hashes

Hashes for google_drive_cli_for_agents-0.1.1.tar.gz
Algorithm Hash digest
SHA256 824b230844c003fbed5681b15d365cd62740289be135c5473bff8185afb2a276
MD5 81681a6ab5cf064b08bfa12e1656c316
BLAKE2b-256 856507c03561d74948ccf7fbce443ed0e063913425fe5a286e4ca951788f8e5d

See more details on using hashes here.

Provenance

The following attestation bundles were made for google_drive_cli_for_agents-0.1.1.tar.gz:

Publisher: publish.yml on NmadeleiDev/google-drive-cli

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file google_drive_cli_for_agents-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for google_drive_cli_for_agents-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 815b07cc70c57871f0744c68c295454ceff7d317e9319ba4e432f58cc7566b0a
MD5 07080795d1c200796bcc16d9dfccd0c2
BLAKE2b-256 ab95489ee38578eae9d9a5eae48874051d0e060d26e8912734dedcaa7d0f2a9d

See more details on using hashes here.

Provenance

The following attestation bundles were made for google_drive_cli_for_agents-0.1.1-py3-none-any.whl:

Publisher: publish.yml on NmadeleiDev/google-drive-cli

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page