问题 'str' 对象没有属性 'sign_in_with_email_and_password(email, password)'

Issue 'str' object has no attribute 'sign_in_with_email_and_password(email, password)'

我正在尝试使用用户在终端上提示的电子邮件和密码登录。

我尝试通过以下代码使用 'pyrebase'、'pyrebase3' 和 'pyrebase4':

def sign_in():
    global auth
    global user
    email = input("Please, enter your email")
    password = input("Please, enter your password")
    user = auth.sign_in_with_email_and_password(email, password)
    get_user_id(user)

但是,我不断收到错误消息: AttributeError: 'str' object has no attribute 'sign_in_with_email_and_password'

应该很简单,但我想不出还有什么可以尝试的!

这对我有用。

def _create_connection(self):
    _firebase = pyrebase.initialize_app(self.config)
    self.auth = _firebase.auth()
    self.user = self.auth.sign_in_with_email_and_password(self.email, self.password)
    self.firebase = _firebase.database()

您是否初始化应用程序并调用了 auth?