这个不可调用但 PyPl 可以工作的 Python 类是什么?

问题描述 投票:0回答:1

我正在尝试将 Google OAuth 2 添加到 Python 3.10 Streamlit 1.33 概念验证应用程序中,我在 https://github.com/mkhorasani/Streamlit-Authenticator 找到了一个小部件,它带有 pip 安装选项。

该选项一直失败,因此我决定将代码下载到我的项目中并在本地运行。我 pip 卸载了该模块,然后将两个页面添加到一个子文件夹中。

现在之前没有问题的代码告诉我“身份验证”不可调用。

这是我的客户端脚本突然出现问题:

from Google.Auth import Authenticate
# This code is now saying it is not callable
authMan = Authenticate(
    secret_credentials_path='./credentials.json',
    cookie_name='My-Cookie-Me',
    cookie_key='abc123',
    redirect_uri=os.environ["CORE_SITE_URL"]
)

这是我从 Github 获得的 Authenticate 类的顶部。

import time
import streamlit as st
from typing import Literal
import google_auth_oauthlib.flow
from googleapiclient.discovery import build

from Google.Auth.cookie import CookieHandler
class Authenticate:
    def __init__(self, secret_credentials_path: str, redirect_uri: str, cookie_name: str, cookie_key: str,
                 cookie_expiry_days: float = 30.0):
        st.session_state['connected'] = st.session_state.get('connected', False)
        self.secret_credentials_path = secret_credentials_path
        self.redirect_uri = redirect_uri
        self.cookie_handler = CookieHandler(cookie_name,
                                            cookie_key,
                                            cookie_expiry_days)

需要明确的是,当我使用 PyPl 参考时,一切都通过在 Google 中进行身份验证来完成,但引用的模块从未更改会话设置。现在我什至无法进行 init 调用。

有人知道为什么这不起作用吗?

谢谢!

python python-3.x google-oauth streamlit
1个回答
0
投票

事实证明,我需要直接导入该类,然后将其用作模块。我有

from Google.Auth import Authenticate

正确的导入是

from Google.Auth.Authenticate import Authenticate
© www.soinside.com 2019 - 2024. All rights reserved.