检查用户是否登录firebase python
我在kivy项目中使用firebase作为我的数据库,如果用户已经登录,我想显示主屏幕,否则显示登录屏幕。我如何知道此人是使用python firebase api登录还是注销的 这是我的密码检查用户是否登录firebase python,python,firebase-authentication,logout,Python,Firebase Authentication,Logout,我在kivy项目中使用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,au
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_管理员:
用于登录的api是,
火基:
您能提供一个指向您正在使用的“python firebase api”的链接吗?这是两个独立的库。你用哪一种?如果我们看到您当前如何与Firebase交互的代码,这可能会有所帮助。您是否可以建议我用于此问题的任何其他API Firebase Admin SDK没有登录用户的逻辑,因为他们没有当前用户的概念。这通常由客户端应用程序完成,然后由AdminSDK从客户端获取ID令牌并验证其是否有效。不幸的是,带有指向库的链接的注释已不存在,因此您是否可以编辑您的问题以包含指向实现
au的库的链接。请使用电子邮件和密码(uid,pas)登录?