def get_credentials(self):
conf_dir = self.get_conf_dir()
credential_path = os.path.join(conf_dir, self.event + '_credentials.json')
store = oauth2client.file.Storage(credential_path)
credentials = store.get()
if not credentials or credentials.invalid:
log.warn("No current valid Google credentials. Starting authentication flow...")
flow = client.flow_from_clientsecrets(os.path.join(conf_dir, 'client_secret.json'),
'https://www.googleapis.com/auth/calendar')
flow.user_agent = "HOTBot"
if self.flags:
credentials = tools.run_flow(flow, store, self.flags)
else: # Needed only for compatibility with Python 2.6
credentials = tools.run(flow, store)
log.info('Storing credentials to ' + credential_path)
return credentials
评论列表
文章目录