Skip to main content

A simple way to work with Google API

Project description

Simple Google API

Python package simple Google API for non-technical users

How to install

Install with Pip

Install new package.

pip install simplegoogleapi

Upgrade to the latest version.

pip install simplegoogleapi --upgrade

Install with GitHub

Install new package.

pip install git+https://github.com/tranngocminhhieu/simplegoogleapi.git

Upgrade to the latest version.

pip install git+https://github.com/tranngocminhhieu/simplegoogleapi --upgrade

How to use SimpleDrive

Import packages

from simplegoogleapi.drive import SimpleDrive
from simplegoogleapi.auth import BuildAuth

Build auth

Build auth with a service account

gauth = BuildAuth(service_account='service_account.json').build_gauth_from_service_account()

Build auth with client secrets and credentials

gauth = BuildAuth(client_secrets_file='client_secrets.json', credentials_file='credentials.json').build_gauth_from_client_secrets()

Build auth automation anyway

gauth = BuildAuth().build_gauth_auto_anyway(client_secrets_file='client_secrets.json', credentials_file='credentials.json', credentials_raw='https://rentry.co/example/raw', service_account_json='service_account.json')

Use functions

my_drive = SimpleDrive(gauth=gauth)

Upload a file

my_drive.upload_file(local_file='your-file-path', folder_id=None, rename=None)

Create a folder

my_drive.create_folder(new_folder_name='New folder', parent_folder_id=None)

Check usage limit

my_drive.check_usage()

List files

files = my_drive.list_files(title_contains=None, owner_email=None)

Delete a file

my_drive.delete_file(file_id='your-file-id')

Move a file

my_drive.move_file(file_id='your-file-id', to_folder_id='your-folder-id')

Copy a file

my_drive.copy_file(file_id='your-file-id', same_name=True, prefix=None, suffix=None, to_folder_id=None)

Rename a file

my_drive.rename_file(file_id='your-file-id', new_name='A new name')

Add a permission

my_drive.add_permission(file_id='your-file-id', email='example@mail.com', role='reader')

Delete a permission

# With a permission ID
my_drive.delete_permission(file_id='your-file-id', permission_id='a-permission-id', email=None)
# With an email
my_drive.delete_permission(file_id='your-file-id', permission_id=None, email='example@mail.com')

Transfer ownership

Transfer ownership with different organization

Method: Copy the old file to a new file > Delete the old file

from simplegoogleapi.drive.help import transfer_owner_by_copy
gauth_from = BuildAuth(service_account='service_account.json').build_gauth_from_service_account()
gauth_to = BuildAuth(client_secrets_file='client_secrets.json', credentials_file='credentials.json').build_gauth_from_client_secrets()
transfer_owner_by_copy(gauth_from, gauth_to, file_id='your-file-id', same_name=True)

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

simplegoogleapi-0.1.0-py3-none-any.whl (3.1 kB view details)

Uploaded Python 3

File details

Details for the file simplegoogleapi-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for simplegoogleapi-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b814f5172f0c6aa11ad58d5abda5b02130901b2c08eeafd3c990dc91f7995b23
MD5 611d5b52488d97af511a35a35426b039
BLAKE2b-256 f85dbb30ae014c4f2374f67b2978e8ea354cb0d5363a0197c5610ef6b54c8ec3

See more details on using hashes here.

Supported by

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