def _load_credentials(cls, keydata):
"""Load ServiceAccountCredentials from Google service account JSON keyfile
Args:
keydata (dict): The loaded keyfile data from a Google service account
JSON file
Returns:
oauth2client.service_account.ServiceAccountCredentials: Instance of
service account credentials for this discovery service
"""
try:
creds = ServiceAccountCredentials.from_json_keyfile_dict(
keydata, scopes=cls._SCOPES)
except (ValueError, KeyError):
# This has the potential to raise errors. See: https://tinyurl.com/y8q5e9rm
LOGGER.exception('Could not generate credentials from keyfile for %s',
cls.type())
return False
return creds
评论列表
文章目录