Search code examples
python-3.xfirebase-authenticationpyrebase

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


I'm trying to logging in with an email and password prompted by the user on terminal.

I tried to use 'pyrebase', 'pyrebase3', and 'pyrebase4' with the following code:

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)

However, I keep getting the error: AttributeError: 'str' object has no attribute 'sign_in_with_email_and_password'

It should be straightforward, but I can't think anything else to try!


Solution

  • This worked for me.

    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()
    

    Did you initialize the app and called auth?