Skip to main content

helper package to interface with required google api services. It is completely independent package for generic usage.

Install

install it from PyPi pip install google-services-helper or run python setup.py install from project root

example-usage

from vedavaapi.google_helper.gsheets import GSheets
from vedavaapi.google_helper.gdrive import GDrive

credentials_file_path = 'path/to/credentials.json'
scopes = ['https://www.googleapis.com/auth/drive.readonly', 'https://www.googleapis.com/auth/spreadsheets.readonly']

#get instance of GSheets helper class, from our credentials.
gsheets_helper = GSheets.from_creds_file(credentials_file_path, scopes)

#now use it to access data in our required valuesFormat with header row mapping, etc.
#we can provide only desired customized parameters in 'pargs' dictionary parameter. if no custom 'fields' are choosen in pargs, then all fields will be returned. if no range mentioned, all sheet values will be returned.
vakyas_sheet_values, statuscode = gsheets_helper.sheet_values_for(spreadsheet_id='someGooGleSheetId',sheet_id='Vakyas', pargs={'idType':'title', 'valuesFormat':'maps', 'fields':['Vakya_id', 'Tantrayukti_tag', 'Vakya'], 'range':'1:27'} )

#get instance of GDrive helper class, from our credentials.
gdrive_helper = GDrive.from_creds_file(credentials_file, scopes)

#now use it to retrieve spreadsheet files details in a google drive folder
list_of_files_in_folder, status_code = gdrive_helper.list_of_files_in_folder(folder_id='bJUyfjaitxkzsl_jagkkahajru2acd', mime_types=['application/vnd.google-apps.spreadsheet'], additional_pargs={'orderBy':'recency'})

above code just passes a credentials.json file and, get a GSheets/GDrive object. with these helper objects we query sheets/drive, etc, with their methods. But if we don't have credentials.json file(it represents owner's authorisation grant to our application), then we have to generate one from our application's client_secret.json file we get from google api console.(this client_secret.json is like id of our app.). in this case resource user, and application owner is same. we have to grant our app permission to access our files. for that fallow below. once credentials.json is there, no need of this.

from vedavaapi.google_helper.oauth import Authorizer

authorizer = Authorizer(client_secret_path='path/to/client_secret.json', credentials_storage_path='path/to/credentials.json', scopes=['https://www.googleapis.com/auth/drive.readonly', 'https://www.googleapis.com/auth/spreadsheets.readonly'])

authorizer.authorize() #this will redirect us to web browser, and after completion of authorisation credentials will be stored at given path. we can use these credentials and start using helper packages like above.

and there is a factory class too, which creates and returns above helper objects from single credentials, and make interlinking them a lot simpler.

from vedavaapi.google_helper import GServices #our factory class

gservices =  GServices.from_creds_file('/path/to/credentialsfile', scopes=scopes) #instantiate a wrapper factory.

#now get required helpers for those credentials from helper factory.
gsheets = gservices.gsheets(enable_drive_service_linking=True) #all arguments are optional.
gdrive = gservices.gdrive()

#then use above helper objects like before.

Download files

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

Source Distribution

google-services-helper-1.0.2.tar.gz (11.1 kB view details)

Uploaded Source

Built Distributions

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

google_services_helper-1.0.2-py3-none-any.whl (13.3 kB view details)

Uploaded Python 3

google_services_helper-1.0.2-py2-none-any.whl (13.3 kB view details)

Uploaded Python 2

File details

Details for the file google-services-helper-1.0.2.tar.gz.

File metadata

  • Download URL: google-services-helper-1.0.2.tar.gz
  • Upload date:
  • Size: 11.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.6.5

File hashes

Hashes for google-services-helper-1.0.2.tar.gz
Algorithm Hash digest
SHA256 0093e2ace105037b436de403b83a26c8108f24466f8233ceca4e235c1224c9a6
MD5 0fe1b44d4daf1069509a53cfa30ed3ec
BLAKE2b-256 c6c132fe2156b22f0a355015f318e8717ad8385b65f757024c64d230d4e8abf4

See more details on using hashes here.

File details

Details for the file google_services_helper-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: google_services_helper-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 13.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.6.5

File hashes

Hashes for google_services_helper-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 36001d12d01a41c3295877e11058de93171cf8f5fbfef4715f00a66bd3992f4a
MD5 bebdb7289f31f9116dc90f76b9ebfd05
BLAKE2b-256 1438425ce4fa8b4df440d570cbf829748d0e96915036ceb143fcffeb575d6df0

See more details on using hashes here.

File details

Details for the file google_services_helper-1.0.2-py2-none-any.whl.

File metadata

  • Download URL: google_services_helper-1.0.2-py2-none-any.whl
  • Upload date:
  • Size: 13.3 kB
  • Tags: Python 2
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.6.5

File hashes

Hashes for google_services_helper-1.0.2-py2-none-any.whl
Algorithm Hash digest
SHA256 8f16c1025cf13dbe689ab97b33692c7a26342031c4e993c75a941e1197ab9162
MD5 52312c4769a16549003dfd6dfa50a797
BLAKE2b-256 d30e3a7b783b2f425df3905b797d25c2c7c0da325b987169ba7b6157c16e8e3f

See more details on using hashes here.

Supported by

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