def Service_Account_Credential():
"""
Utilizes the Service Account Credential flow to instantiate an authorized credentials
object for calling the Google API
"""
logging.debug('DEBUG: SAC_FLOW: Attemping to load settings file from %s' % settings.servicekeyfile)
keyfile = settings.servicekeyfile
logging.debug('DEBUG: SAC_FLOW: Finished loading Service Account Keyfile: using %s' % keyfile )
logging.debug('DEBUG: SAC_FLOW: Loading scopes from settings file')
scopes = settings.scopes
logging.debug('DEBUG: SAC_FLOW: Finished loading scopes from settings file')
logging.debug('DEBUG: SAC_FLOW: Initializing credential from oauth2client.service_account')
credentials = ServiceAccountCredentials.from_json_keyfile_name(keyfile,
scopes=scopes)
logging.debug('DEBUG: SAC_FLOW: Delegating credentials from settings')
delegated_credentials = credentials.create_delegated(settings.delegated_email)
logging.debug('DEBUG: SAC_FLOW:Initializing authorized, delegated credentials object')
http = delegated_credentials.authorize(httplib2.Http())
return http
评论列表
文章目录