def get_credentials(self, client_secret_file, scopes, credentials_dir, credentials_file, flags=None):
# Create credentials folder, if necessary
if not os.path.exists(credentials_dir):
os.makedirs(credentials_dir)
# Store for credentials file
credential_path = os.path.join(credentials_dir, credentials_file)
store = Storage(credential_path)
credentials = store.get()
if not credentials or credentials.invalid:
flow = client.flow_from_clientsecrets(client_secret_file, scopes)
flow.user_agent = APPLICATION_NAME
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)
self._logger.debug("Storing credentials to '{}'".format(credential_path))
else:
self._logger.debug("Got valid credential from '{}'".format(credential_path))
return credentials
# Create a Google Calendar API service object
google_calendar.py 文件源码
python
阅读 24
收藏 0
点赞 0
评论 0
评论列表
文章目录