google api helper for vedavaapi project
Project description
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.
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
Built Distributions
Hashes for google-services-helper-1.0.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 180213bbee4c6ce790455918c9377654096be53c7d8f71f105214544b877b44a |
|
MD5 | 4a3305a2395f7f634a48d175ba7f3806 |
|
BLAKE2b-256 | a0beecc31688e0f0ac0888d66efc4c03f5f343b63c888f27a1f3b376ed015d23 |
Hashes for google_services_helper-1.0.1-py3.6.egg
Algorithm | Hash digest | |
---|---|---|
SHA256 | a3cb1f9cdbad00a6a30548f8eba57edc45dfaa0d1baf49322241aeca918e2c9c |
|
MD5 | 67844191faef2048af833a47e4173a9b |
|
BLAKE2b-256 | e4c16ff7c13a30f69ea17b30015b034666c5a4e2b3ed902c945c9faa92fe1887 |
Hashes for google_services_helper-1.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 892a1e812a5cf4fa3ecc2ed1f3193738ad6204f05a3cf77d88e7cbd7963ac210 |
|
MD5 | f44b46ede1bdea6faa5a2d6a864d00d4 |
|
BLAKE2b-256 | 61d8ee7d77a764cd3d495e39b1f838ab7166dc11992a74092f1ceab3255d3af8 |
Hashes for google_services_helper-1.0.1-py2.7.egg
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3d23c96921984495a24020133b0e4bd58345fce2518dcdc2c40f2035722c4f0c |
|
MD5 | 235c6723ed7ebaccac6e216c7e0b3694 |
|
BLAKE2b-256 | b58dacf6e9d02283e1638da3b6cedb6ecf7fadbdfa9000aa02c9d10bb6c13fc5 |
Hashes for google_services_helper-1.0.1-py2-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a6d34cbe9aa2f60aaf71a43c892651865c52f579bedee2059ff15272f00b59d8 |
|
MD5 | 6a6b1defaeebf134a02d24b5c8902962 |
|
BLAKE2b-256 | f88af50be600b327d928a5be30b449f31aff131a8abcd6394850de4dc91be647 |