gsuite2mfe.py 文件源码

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

项目:gsuite2mfe 作者: andywalden 项目源码 文件源码
def get_credentials(self):
        """
        Returns 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.
        """
        self.home_dir = os.path.expanduser('~')
        self.credential_dir = os.path.join(self.home_dir, '.credentials')
        if not os.path.exists(self.credential_dir):
            logging.debug("Cred directory not found...creating: %s", self.credential_dir)
            os.makedirs(self.credential_dir)
        self.credential_path = os.path.join(self.credential_dir,
                                       'admin-reports_v1-python-quickstart.json')

        self.store = Storage(self.credential_path)
        self.credentials = self.store.get()
        if not self.credentials or self.credentials.invalid:
            if not os.path.isfile(self.client_file):
                logging.error("'client_secret.json file is missing. \
                                 Google OAuth must be configured")
                sys.exit(1)

            self.flow = client.flow_from_clientsecrets(self.client_file, self.scope)
            self.flow.user_agent = self.appname
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号