google_calendar.py 文件源码

python
阅读 18 收藏 0 点赞 0 评论 0

项目:docker-iot-calendar 作者: masterandrey 项目源码 文件源码
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())
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号