INNER CODE UNIT · Python
_get_service_credentials
Squarespace/datasheets · datasheets/client.py:240
def _get_service_credentials(self):
"""Get credentials for a service account
Uses the service key stored at ``$DATASHEETS_SERVICE_PATH``
(default: ``~/.datasheets/service_key.json``) to get service account credentials. At the
time this method returns the instance has not yet been authenticated / authorized.
Returns:
google.oauth2.service_account.Credentials: instance of service credentials
"""
unexpanded_service_key_path = os.environ.get('DATASHEETS_SERVICE_PATH',
'~/.datasheets/service_key.json')
service_key_path = os.path.expanduser(unexpanded_service_key_path)
with open(service_key_path) as f:
keyfile_dict = json.load(f)
self.email = keyfile_dict['client_email'] # used in __repr__
return service_account.Credentials.from_service_account_file(