auth.py 文件源码

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

项目:SNH48Live 作者: SNH48Live 项目源码 文件源码
def get_authenticated_http_client(args, oauth_scopes):
    if args is None:
        args = ArgumentParser().parse_args([])
    if isinstance(oauth_scopes, str):
        # Singleton
        oauth_scopes = [oauth_scopes]
    flow = oauth2client.client.flow_from_clientsecrets(
        CLIENT_SECRETS_FILE,
        scope=' '.join(f'https://www.googleapis.com/auth/{scope}' for scope in oauth_scopes),
        message=MISSING_CLIENT_SECRETS_MESSAGE,
    )
    oauth_credentials_file = CONFIGS_DIR / f'credentials-{",".join(oauth_scopes)}.json'
    storage = oauth2client.file.Storage(oauth_credentials_file)
    credentials = storage.get()
    if credentials is None or credentials.invalid:
        credentials = oauth2client.tools.run_flow(flow, storage, args)
    return credentials.authorize(httplib2.Http())
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号