微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

检查用户是否登录了firebase python

如何解决检查用户是否登录了firebase python

我在基维项目中使用firebase作为我的数据库,如果用户已经登录,我想显示主屏幕,否则显示登录屏幕。我怎么知道该人是使用python firebase api登录还是注销 这是我的代码

from kivymd.app import MDApp
from kivymd.toast import toast
import firebase_admin
from firebase import Firebase
from firebase_admin import credentials,auth
from firebase_admin import db

cred = credentials.Certificate("C:/Users/RAJAT/Downloads/fir-50c26-firebase-adminsdk-rwle3-a9063a3375.json")
firebase_admin.initialize_app(cred,{'databaseURL':'https://fir-50c26.firebaseio.com/'})

config={
            'apiKey':'AIzaSyCuvad-ZHHXVRp1Ly3AyOwgpPgG1zi-wJs','authDomain':'fir-50c26.firebaseapp.com','databaseURL':'https://fir-50c26.firebaseio.com/','storageBucket':'fir-50c26.appspot.com','serviceAccount':'C:/Users/RAJAT/Downloads/fir-50c26-firebase-adminsdk-rwle3-a9063a3375.json'
}
fb=Firebase(config)
au=fb.auth()

class DemoApp(MDApp):

    def login(self):
        uid = self.root.ids.username.text
        pas = self.root.ids.password.text
        try:
            hi=au.sign_in_with_email_and_password(uid,pas)
            self.root.current = 's3'
            print(hi)
            print('success')
        except Exception as e:
            e=str(e)
            e=e.split(':')
            e=e[6]
            e=e.split(',')[0]
            toast(e)

    def signup(self):
        usn=self.root.ids.User.text
        email=self.root.ids.Email.text
        phone=self.root.ids.Phone.text
        phone='+91'+phone
        pas=self.root.ids.Pass.text
        try:
            self.usr = auth.create_user(uid=usn,display_name=usn,phone_number=phone,email=email,password=pas)
        except Exception as err:
            err=str(err)
            toast(err)

    def signedinorno(self):
        uid='raj'
        user=auth.get_user(uid)
        ar=au.get_account_info(user['idToken'])



DemoApp().run()

在这里我使用了2个api,因为我猜python_firebase没有提供登录选项,因为我没有在文档中得到它。这是我使用的库的链接, firebase_admin: https://pypi.org/project/firebase-admin/ 用于登录的api是 火力: https://pypi.org/project/firebase/

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。