I couldn't make a login screen with pyrebase4. I'm getting this error:
AttributeError: 'function' object has no attribute 'sign_in_with_email_and_password'
Creating user is also not possible and it gives the error:
AttributeError: 'function' object has no attribute 'create_user_with_email_and_password'
I'm using pyrebase4 since I read that the original pyrebase was discontinued. I saw more than one video of people just writing the code exactly like I did and theirs seem to just work. I don't understand why mine doesn't.
main.py
from kivymd.app import MDApp
from kivy.lang import Builder
from kivy.uix.screenmanager import ScreenManager, Screen
import pyrebase
class MainApp(MDApp):
def build(self):
return Builder.load_file('main.kv')
firebaseConfig = {
'''write your config here'''
}
firebase = pyrebase.initialize_app(firebaseConfig)
auth = firebase.auth
def login(self):
email = self.root.get_screen("test1win").ids.user_mail.text
password = self.root.get_screen("test1win").ids.password.text
login = self.auth.sign_in_with_email_and_password(email, password)
self.root.current = "test2win"
print("Login Success")
class WindowManager(ScreenManager):
pass
class TestWindow1(Screen):
pass
class TestWindow2(Screen):
pass
if __name__ == "__main__":
MainApp().run()
main.kv
#: include testwindow1.kv
#: include testwindow2.kv
WindowManager:
TestWindow1:
TestWindow2:
testwindow1.kv
<TestWindow1>:
name: "test1win"
Screen:
BoxLayout:
orientation: 'vertical'
MDTextField:
id: user_mail
hint_text: "E-Mail"
size_hint_x: 0.8
pos_hint: {"center_x": 0.5}
font_size: 24
mode: "rectangle"
MDTextField:
id: password
hint_text: "Password"
size_hint_x: 0.8
font_size: 24
pos_hint: {"center_x": 0.5}
mode: "rectangle"
MDRaisedButton:
text: "Login"
pos_hint: {"center_x": 0.5}
on_release: app.login()
Widget:
testwindow2.kv
<TestWindow2>:
name: "test2win"
Screen:
MDLabel:
text: "You're logged in"
I think your code:
auth = firebase.auth
should be:
auth = firebase.auth()
Note the parens.