def get_credentials_http(self):
if not os.path.isfile(self.settings[GOOGLE_CREDENTIALS_PARAM]):
print('''Google API credentials file {} not found.
Get it on https://console.developers.google.com/start/api?id=calendar'''.format(
self.settings[GOOGLE_CREDENTIALS_PARAM]
))
return None
try:
credentials = ServiceAccountCredentials.from_json_keyfile_name(
self.settings[GOOGLE_CREDENTIALS_PARAM],
[
'https://www.googleapis.com/auth/calendar'
]
)
except Exception as e:
print('''Cannot login to Google API - check your credential file {}.
You can get new one from https://console.developers.google.com/start/api?id=calendar'''.format(
self.settings[GOOGLE_CREDENTIALS_PARAM]
))
return None
return credentials.authorize(httplib2.Http())
google_calendar.py 文件源码
python
阅读 18
收藏 0
点赞 0
评论 0
评论列表
文章目录