<h1 align="center"> google drive python </h1> <br>
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==<VERSION>
```
# 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 <path-to-credentials-file.json>
```
## google-drive ls
List directory contents
### Usage
```
> google-drive ls <directory>/<maybe-some-subdir> <path-to-credentials-file.json>
- (<GOOGLE_DOC_ID_1>, <FILENAME_1>, <FILE_MIMETYPE_1>)
- (<GOOGLE_DOC_ID_2>, <FILENAME_2>, <FILE_MIMETYPE_2>)
- (<GOOGLE_DOC_ID_3>, <FILENAME_3>, <FILE_MIMETYPE_3>)
...
- (<GOOGLE_DOC_ID_N>, <FILENAME_N>, <FILE_MIMETYPE_N>)
```
## google-drive get
Get file metadata
### Usage
```
> google-drive get <GOOGLE_DOC_ID> <path-to-credentials-file.json>
File Metadata:
==
id: <GOOGLE_DOC_ID>
name: <FILENAME>
parents: ['<GOOGLE_DOC__PARENT_ID>']
mime_type: <FILE_MIMETYPE>
export_links:
- application/rtf: https://docs.google.com/feeds/download/documents/export/Export?id=<GOOGLE_DOC_ID>&exportFormat=rtf
- application/vnd.oasis.opendocument.text: https://docs.google.com/feeds/download/documents/export/Export?id=<GOOGLE_DOC_ID>&exportFormat=odt
- text/html: https://docs.google.com/feeds/download/documents/export/Export?id=<GOOGLE_DOC_ID>&exportFormat=html
- application/pdf: https://docs.google.com/feeds/download/documents/export/Export?id=<GOOGLE_DOC_ID>&exportFormat=pdf
- application/epub+zip: https://docs.google.com/feeds/download/documents/export/Export?id=<GOOGLE_DOC_ID>&exportFormat=epub
- application/zip: https://docs.google.com/feeds/download/documents/export/Export?id=<GOOGLE_DOC_ID>&exportFormat=zip
- application/vnd.openxmlformats-officedocument.wordprocessingml.document: https://docs.google.com/feeds/download/documents/export/Export?id=<GOOGLE_DOC_ID>&exportFormat=docx
- text/plain: https://docs.google.com/feeds/download/documents/export/Export?id=<GOOGLE_DOC_ID>&exportFormat=txt
```
## google-drive mkdir
Make directory
### Usage
```
> google-drive mkdir <DIR_NAME> <path-to-credentials-file.json>
(<GOOGLE_DOC_ID>, <DIR_NAME>, application/vnd.google-apps.folder)
```
## google-drive touch
Create empty file of specified mimetype
### Usage
```
> google-drive touch <EXISTING_DIR>/<FILENAME> <SOME_MYMETYPE> <path-to-credentials-file.json>
(<GOOGLE_DOC_ID>, <FILENAME>, <SOME_MYMETYPE>)
```
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](<CONTRIBUTING.md>) and [Style Guide](<STYLE.md>) 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).
Raw data
{
"_id": null,
"home_page": "https://github.com/eduardogr/google-drive-python",
"name": "google-drive",
"maintainer": "Eduardo Garc\u00eda",
"docs_url": null,
"requires_python": "",
"maintainer_email": "garciaruiz.edu+google-drive-python@gmail.com",
"keywords": "google drive",
"author": "Eduardo Garcia",
"author_email": "garciaruiz.edu+maintain+google-drive-python@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/de/dc/b184be11ecfbd9884b4a70a1ab675c6c9eff65fcad698175fef258b3da9c/google-drive-0.5.1.tar.gz",
"platform": null,
"description": "<h1 align=\"center\"> google drive python </h1> <br>\n\nLibrary and cli to manage and interact with your Google Drive, sheets and docs\n\n- https://pypi.org/project/google-drive/ \n\n\n## Table of Contents\n\n1. [Introduction](#introduction)\n1. [Obtaining credentials for Google APIs](#obtaining-credentials-for-google-apis)\n1. [Installing google-drive CLI](#installing-google-drive-cli)\n1. [CLI Documentation](#cli-documentation)\n1. [Contributing](#contributing)\n1. [License](#license)\n\n# Introduction \n[![Build Status](https://travis-ci.org/eduardogr/google-drive-python.svg?branch=main)](https://travis-ci.org/github/eduardogr/google-drive-python)\n[![codecov](https://codecov.io/gh/eduardogr/google-drive-python/branch/main/graph/badge.svg?token=E183Y3LLXX)](https://codecov.io/gh/eduardogr/google-drive-python)\n[![Python](https://img.shields.io/badge/Python-v3.6%2B-blue)]()\n[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](CONTRIBUTING.md)\n[![GitHub license](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://github.com/eduardogr/google-drive-python/blob/main/LICENSE) \n\n## Obtaining credentials for Google APIs\n\n### Google API credentials\n\n#### Create a Google project :zap:\n\nJust access to [Google APIs](https://console.developers.google.com/).\n\n - Or [click here](https://console.developers.google.com/projectcreate) for a quick project creation.\n\n#### Create credentials for your project :key:\n\nOnce you have created your project, you can create your project's credentials.\n\nTo 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:\n\n - First, you have to create the [consent](https://console.developers.google.com/apis/credentials/consent) for your project\n - Once the consent is already created and you have a name for you google app you can create your credentials:\n - Go to *+ Create Credentials* and select *OAuth ID client*\n - Or access to [api/credentials/oauthclient](https://console.developers.google.com/apis/credentials/oauthclient)\n - The OAuth client type is *other* and choose the name you prefer :smiley:\n\nYou have already created your credentials! :fireworks:\n\nJust place them in a `credentials.json` file in the root of this repository. :heavy_exclamation_mark::heavy_exclamation_mark:\n\n#### Enable Google APIs :books:\n\nYou can see where you have to access for each google api in the doc [google apis usage](./google-apis-usage.md)\n\n#### Generating your token.pickle :unlock:\n\nTo authenticate us we have to send a token.pickle to Google APIs, this token.pickle is generated using the file credentials.json.\n\nTo generate this we have the make target google-auth, so, you just have to tun\n\n - `make google-auth`\n\n\n:warning: Credentials files to authenticate yourself are included in our [.gitignore](.gitignore)\n\n:angel: So, you don't have to worry about that :smiley:\n\n\n# Installing google-drive CLI\n\n## Using make\n\n```\nmake install\n```\n\n## Using pip\n\n```\npip install google-drive\n```\n\n### With specific version\n\nLook for available versions with:\n\n```\npip install google-drive==\n```\n\nAnd select one and run:\n\n```\npip install google-drive==<VERSION>\n```\n\n# CLI Documentation\n\n## google-drive --help\n\nShows the help message\n\n### Usage\n\n```\n> google-drive --help\nUsage: google-drive [OPTIONS] COMMAND [ARGS]...\n\nOptions:\n --help Show this message and exit.\n\nCommands:\n get Get file metadata\n get-mimetypes Get Mimetypes availables in this API implementation\n login Perform a login with google oauth\n ls List directory contents\n mkdir Make directory\n```\n\n## google-drive get-mimetypes\n\nGet Mimetypes availables in this API implementation\n\n### Usage\n\n```\n> google-drive get-mimetypes credentials.json\n - application/vnd.google-apps.folder\n - application/vnd.google-apps.document\n - application/vnd.google-apps.spreadsheet\n - application/pdf\n```\n\n## google-drive login\n\nPerform a login with google oauth.\n\n### Usage\n\n```\n> google-drive login <path-to-credentials-file.json>\n```\n\n## google-drive ls\n\nList directory contents\n\n### Usage\n\n```\n> google-drive ls <directory>/<maybe-some-subdir> <path-to-credentials-file.json>\n- (<GOOGLE_DOC_ID_1>, <FILENAME_1>, <FILE_MIMETYPE_1>)\n- (<GOOGLE_DOC_ID_2>, <FILENAME_2>, <FILE_MIMETYPE_2>)\n- (<GOOGLE_DOC_ID_3>, <FILENAME_3>, <FILE_MIMETYPE_3>)\n...\n- (<GOOGLE_DOC_ID_N>, <FILENAME_N>, <FILE_MIMETYPE_N>)\n```\n\n## google-drive get\n\nGet file metadata\n\n### Usage\n\n```\n> google-drive get <GOOGLE_DOC_ID> <path-to-credentials-file.json>\n\nFile Metadata:\n==\nid: <GOOGLE_DOC_ID>\nname: <FILENAME>\nparents: ['<GOOGLE_DOC__PARENT_ID>']\nmime_type: <FILE_MIMETYPE>\nexport_links:\n - application/rtf: https://docs.google.com/feeds/download/documents/export/Export?id=<GOOGLE_DOC_ID>&exportFormat=rtf\n - application/vnd.oasis.opendocument.text: https://docs.google.com/feeds/download/documents/export/Export?id=<GOOGLE_DOC_ID>&exportFormat=odt\n - text/html: https://docs.google.com/feeds/download/documents/export/Export?id=<GOOGLE_DOC_ID>&exportFormat=html\n - application/pdf: https://docs.google.com/feeds/download/documents/export/Export?id=<GOOGLE_DOC_ID>&exportFormat=pdf\n - application/epub+zip: https://docs.google.com/feeds/download/documents/export/Export?id=<GOOGLE_DOC_ID>&exportFormat=epub\n - application/zip: https://docs.google.com/feeds/download/documents/export/Export?id=<GOOGLE_DOC_ID>&exportFormat=zip\n - application/vnd.openxmlformats-officedocument.wordprocessingml.document: https://docs.google.com/feeds/download/documents/export/Export?id=<GOOGLE_DOC_ID>&exportFormat=docx\n - text/plain: https://docs.google.com/feeds/download/documents/export/Export?id=<GOOGLE_DOC_ID>&exportFormat=txt\n ```\n\n## google-drive mkdir\n\nMake directory\n\n### Usage\n\n```\n> google-drive mkdir <DIR_NAME> <path-to-credentials-file.json>\n(<GOOGLE_DOC_ID>, <DIR_NAME>, application/vnd.google-apps.folder)\n```\n\n## google-drive touch\n\nCreate empty file of specified mimetype\n\n### Usage\n\n```\n> google-drive touch <EXISTING_DIR>/<FILENAME> <SOME_MYMETYPE> <path-to-credentials-file.json>\n(<GOOGLE_DOC_ID>, <FILENAME>, <SOME_MYMETYPE>)\n```\n\nIt could raise `MissingGoogleDriveFolderException` when parent directories do not exist.\n\n# Using googledrive as API SDK\n\n## Contributing\n\n[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](CONTRIBUTING.md)\n\nContributions are welcome! Please see our [Contributing Guide](<CONTRIBUTING.md>) and [Style Guide](<STYLE.md>) for more\ndetails. \n\nYou can visit our [TODO](TODO.md) list :)\n\n## License\n\nThis project is licensed under the [Apache license](https://github.com/eduardogr/google-drive-python/blob/main/LICENSE).\n",
"bugtrack_url": null,
"license": "Apache",
"summary": "Library and cli to manage and interact with your Google Drive",
"version": "0.5.1",
"project_urls": {
"Homepage": "https://github.com/eduardogr/google-drive-python"
},
"split_keywords": [
"google",
"drive"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "fabcff28f6b41cfdac511ddc3086bb47a6045f9ca947fa9b921cdbe278f95cbc",
"md5": "10fb48aa226e0de02b958b98c96fb061",
"sha256": "479d704b3737b005dba7b8f9c8bd4566b8562e1a88b56b66fe0a0634d99a9900"
},
"downloads": -1,
"filename": "google_drive-0.5.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "10fb48aa226e0de02b958b98c96fb061",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 15017,
"upload_time": "2023-12-05T21:03:11",
"upload_time_iso_8601": "2023-12-05T21:03:11.008288Z",
"url": "https://files.pythonhosted.org/packages/fa/bc/ff28f6b41cfdac511ddc3086bb47a6045f9ca947fa9b921cdbe278f95cbc/google_drive-0.5.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "dedcb184be11ecfbd9884b4a70a1ab675c6c9eff65fcad698175fef258b3da9c",
"md5": "79287c08a528e47ed9d287e8a2dd28e7",
"sha256": "7ccf6a6b1ceb36d0f2719268caa6268ec9d4443495dac4168b632f7177dbb0b1"
},
"downloads": -1,
"filename": "google-drive-0.5.1.tar.gz",
"has_sig": false,
"md5_digest": "79287c08a528e47ed9d287e8a2dd28e7",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 16447,
"upload_time": "2023-12-05T21:03:12",
"upload_time_iso_8601": "2023-12-05T21:03:12.934758Z",
"url": "https://files.pythonhosted.org/packages/de/dc/b184be11ecfbd9884b4a70a1ab675c6c9eff65fcad698175fef258b3da9c/google-drive-0.5.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-12-05 21:03:12",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "eduardogr",
"github_project": "google-drive-python",
"travis_ci": true,
"coveralls": false,
"github_actions": false,
"lcname": "google-drive"
}