Skip to main content

Library and cli to manage and interact with your Google Drive

Project description

google drive python

Library and cli to manage and interact with your Google Drive, sheets and docs

Table of Contents

  1. Introduction
  2. Obtaining credentials for Google APIs
  3. Installing google-drive CLI
  4. CLI Documentation
  5. Contributing
  6. License


Build Status codecov Python PRs Welcome GitHub license

Obtaining credentials for Google APIs

Google API credentials

Create a Google project :zap:

Just access to Google APIs.

Create credentials for your project :key:

Once you have created your project, you can create your project's credentials.

To manage project's credentials you have the section api/credentials within Google APIs. But if this is your first credentials creation you better follow these steps:

  • First, you have to create the consent for your project
  • Once the consent is already created and you have a name for you google app you can create your credentials:
    • Go to + Create Credentials and select OAuth ID client
    • Or access to api/credentials/oauthclient
    • The OAuth client type is other and choose the name you prefer :smiley:

You have already created your credentials! :fireworks:

Just place them in a credentials.json file in the root of this repository. :heavy_exclamation_mark::heavy_exclamation_mark:

Enable Google APIs :books:

You can see where you have to access for each google api in the doc google apis usage

Generating your token.pickle :unlock:

To authenticate us we have to send a token.pickle to Google APIs, this token.pickle is generated using the file credentials.json.

To generate this we have the make target google-auth, so, you just have to tun

  • make google-auth

:warning: Credentials files to authenticate yourself are included in our .gitignore

:angel: So, you don't have to worry about that :smiley:

Installing google-drive CLI

Using make

make install

Using pip

pip install google-drive

With specific version

Look for available versions with:

pip install google-drive==

And select one and run:

pip install google-drive==<VERSION>

CLI Documentation

google-drive --help

Shows the help message


> google-drive --help
Usage: google-drive [OPTIONS] COMMAND [ARGS]...

  --help  Show this message and exit.

  get    Get file metadata
  get-mimetypes  Get Mimetypes availables in this API implementation
  login  Perform a login with google oauth
  ls     List directory contents
  mkdir  Make directory

google-drive get-mimetypes

Get Mimetypes availables in this API implementation


>  google-drive get-mimetypes credentials.json
  - application/
  - application/
  - application/
  - application/pdf

google-drive login

Perform a login with google oauth.


> google-drive login <path-to-credentials-file.json>

google-drive ls

List directory contents


> google-drive ls <directory>/<maybe-some-subdir> <path-to-credentials-file.json>

google-drive get

Get file metadata


> google-drive get <GOOGLE_DOC_ID> <path-to-credentials-file.json>

File Metadata:
name: <FILENAME>
parents: ['<GOOGLE_DOC__PARENT_ID>']
mime_type: <FILE_MIMETYPE>
  - application/rtf:<GOOGLE_DOC_ID>&exportFormat=rtf
  - application/vnd.oasis.opendocument.text:<GOOGLE_DOC_ID>&exportFormat=odt
  - text/html:<GOOGLE_DOC_ID>&exportFormat=html
  - application/pdf:<GOOGLE_DOC_ID>&exportFormat=pdf
  - application/epub+zip:<GOOGLE_DOC_ID>&exportFormat=epub
  - application/zip:<GOOGLE_DOC_ID>&exportFormat=zip
  - application/vnd.openxmlformats-officedocument.wordprocessingml.document:<GOOGLE_DOC_ID>&exportFormat=docx
  - text/plain:<GOOGLE_DOC_ID>&exportFormat=txt

google-drive mkdir

Make directory


> google-drive mkdir <DIR_NAME> <path-to-credentials-file.json>
(<GOOGLE_DOC_ID>, <DIR_NAME>, application/

google-drive touch

Create empty file of specified mimetype


> google-drive touch <EXISTING_DIR>/<FILENAME> <SOME_MYMETYPE> <path-to-credentials-file.json>

It could raise MissingGoogleDriveFolderException when parent directories do not exist.

Using googledrive as API SDK


PRs Welcome

Contributions are welcome! Please see our Contributing Guide for more details.

You can visit our TODO list :)


This project is licensed under the Apache license.

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-0.5.0.tar.gz (13.7 kB view hashes)

Uploaded source

Built Distribution

google_drive-0.5.0-py3-none-any.whl (15.0 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page