GDrive.py 文件源码

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

项目:lib9 作者: Jumpscale 项目源码 文件源码
def initClientSecret(self, path='client_secrets.json'):
        """Gets valid user credentials from storage.

        If nothing has been stored, or if the stored credentials are invalid,
        the OAuth2 flow is completed to obtain the new credentials.

        Returns:
            Credentials, the obtained credential.
        """
        if not j.sal.fs.exists(path, followlinks=True):
            raise j.exceptions.Input(message="Could not find google secrets file in %s, please dwonload" %
                                     path, level=1, source="", tags="", msgpub="")
        store = Storage(self.secretsFilePath)
        self._credentials = store.get()
        if not j.sal.fs.exists(self.secretsFilePath) or not self._credentials or self._credentials.invalid:
            flow = client.flow_from_clientsecrets(path, SCOPES)
            flow.user_agent = APPLICATION_NAME
            self._credentials = tools.run_flow(flow, store)
            # credentials = tools.run(flow, store)
            self.logger.info('Storing credentials to ' + self.secretsFilePath)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号