Last active
December 6, 2018 12:58
-
-
Save kmonsoor/d89c930a8df3060106c04648dc6058b0 to your computer and use it in GitHub Desktop.
Python get_credential() for Google service_account() with *.json secret. ⭐ this gist if acts as useful, as a 👍
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_credential_service_account(): | |
from oauth2client.service_account import ServiceAccountCredentials | |
SERVICE_ACC_CREDENTIAL = 'your-service-account-secrets-file.json' | |
scopes = ['https://www.googleapis.com/auth/drive'] | |
pprint("Request for credential received"); | |
try: | |
credentials = ServiceAccountCredentials.from_json_keyfile_name(SERVICE_ACC_CREDENTIAL, scopes=scopes) | |
pprint(credentials) | |
return credentials | |
except Exception as e: | |
pprint("Failed to obtain valid credential") | |
raise |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment