def getSvcAcctCredentials(scopes, act_as):
try:
if not GM.Globals[GM.OAUTH2SERVICE_JSON_DATA]:
json_string = readFile(GC.Values[GC.OAUTH2SERVICE_JSON], continueOnError=True, displayError=True)
if not json_string:
invalidOauth2serviceJsonExit()
GM.Globals[GM.OAUTH2SERVICE_JSON_DATA] = json.loads(json_string)
credentials = oauth2client.service_account.ServiceAccountCredentials.from_json_keyfile_dict(GM.Globals[GM.OAUTH2SERVICE_JSON_DATA], scopes)
credentials = credentials.create_delegated(act_as)
credentials.user_agent = GAM_INFO
serialization_data = credentials.serialization_data
GM.Globals[GM.ADMIN] = serialization_data[u'client_email']
GM.Globals[GM.OAUTH2_CLIENT_ID] = serialization_data[u'client_id']
return credentials
except (ValueError, IndexError, KeyError):
invalidOauth2serviceJsonExit()
评论列表
文章目录