Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/eduardogr/google-drive-python
Library and cli to manage and interact with your Google Drive. https://pypi.org/project/google-drive/
https://github.com/eduardogr/google-drive-python
google-api google-drive python
Last synced: about 1 month ago
JSON representation
Library and cli to manage and interact with your Google Drive. https://pypi.org/project/google-drive/
- Host: GitHub
- URL: https://github.com/eduardogr/google-drive-python
- Owner: eduardogr
- License: apache-2.0
- Created: 2020-11-14T00:45:11.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2023-12-05T21:07:51.000Z (about 1 year ago)
- Last Synced: 2024-10-11T02:49:19.562Z (2 months ago)
- Topics: google-api, google-drive, python
- Language: Python
- Homepage:
- Size: 88.9 KB
- Stars: 16
- Watchers: 4
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
google drive python
Library and cli to manage and interact with your Google Drive, sheets and docs
- https://pypi.org/project/google-drive/
## Table of Contents
1. [Introduction](#introduction)
1. [Obtaining credentials for Google APIs](#obtaining-credentials-for-google-apis)
1. [Installing google-drive CLI](#installing-google-drive-cli)
1. [CLI Documentation](#cli-documentation)
1. [Contributing](#contributing)
1. [License](#license)# Introduction
[![Build Status](https://travis-ci.org/eduardogr/google-drive-python.svg?branch=main)](https://travis-ci.org/github/eduardogr/google-drive-python)
[![codecov](https://codecov.io/gh/eduardogr/google-drive-python/branch/main/graph/badge.svg?token=E183Y3LLXX)](https://codecov.io/gh/eduardogr/google-drive-python)
[![Python](https://img.shields.io/badge/Python-v3.6%2B-blue)]()
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](CONTRIBUTING.md)
[![GitHub license](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://github.com/eduardogr/google-drive-python/blob/main/LICENSE)## Obtaining credentials for Google APIs
### Google API credentials
#### Create a Google project :zap:
Just access to [Google APIs](https://console.developers.google.com/).
- Or [click here](https://console.developers.google.com/projectcreate) for a quick project creation.
#### 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](https://console.developers.google.com/apis/credentials) within [Google APIs](https://console.developers.google.com/). But if this is your first credentials creation you better follow these steps:
- First, you have to create the [consent](https://console.developers.google.com/apis/credentials/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](https://console.developers.google.com/apis/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](./google-apis-usage.md)
#### 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](.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==
```# CLI Documentation
## google-drive --help
Shows the help message
### Usage
```
> google-drive --help
Usage: google-drive [OPTIONS] COMMAND [ARGS]...Options:
--help Show this message and exit.Commands:
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
### Usage
```
> google-drive get-mimetypes credentials.json
- application/vnd.google-apps.folder
- application/vnd.google-apps.document
- application/vnd.google-apps.spreadsheet
- application/pdf
```## google-drive login
Perform a login with google oauth.
### Usage
```
> google-drive login
```## google-drive ls
List directory contents
### Usage
```
> google-drive ls /
- (, , )
- (, , )
- (, , )
...
- (, , )
```## google-drive get
Get file metadata
### Usage
```
> google-drive getFile Metadata:
==
id:
name:
parents: ['']
mime_type:
export_links:
- application/rtf: https://docs.google.com/feeds/download/documents/export/Export?id=&exportFormat=rtf
- application/vnd.oasis.opendocument.text: https://docs.google.com/feeds/download/documents/export/Export?id=&exportFormat=odt
- text/html: https://docs.google.com/feeds/download/documents/export/Export?id=&exportFormat=html
- application/pdf: https://docs.google.com/feeds/download/documents/export/Export?id=&exportFormat=pdf
- application/epub+zip: https://docs.google.com/feeds/download/documents/export/Export?id=&exportFormat=epub
- application/zip: https://docs.google.com/feeds/download/documents/export/Export?id=&exportFormat=zip
- application/vnd.openxmlformats-officedocument.wordprocessingml.document: https://docs.google.com/feeds/download/documents/export/Export?id=&exportFormat=docx
- text/plain: https://docs.google.com/feeds/download/documents/export/Export?id=&exportFormat=txt
```## google-drive mkdir
Make directory
### Usage
```
> google-drive mkdir
(, , application/vnd.google-apps.folder)
```## google-drive touch
Create empty file of specified mimetype
### Usage
```
> google-drive touch /
(, , )
```It could raise `MissingGoogleDriveFolderException` when parent directories do not exist.
# Using googledrive as API SDK
## Contributing
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](CONTRIBUTING.md)
Contributions are welcome! Please see our [Contributing Guide]() and [Style Guide]() for more
details.You can visit our [TODO](TODO.md) list :)
## License
This project is licensed under the [Apache license](https://github.com/eduardogr/google-drive-python/blob/main/LICENSE).