如何使用Python向Firebase进行身份验证? [英] How to authenticate to Firebase using Python?

查看:82
本文介绍了如何使用Python向Firebase进行身份验证?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Python构建Web应用程序,我想对用户进行身份验证. pyrebase软件包似乎已过时,并且会生成依赖项错误,因此我无法使用它. 我知道firebase-admin API中有一个功能如下:

I am building a Web App with Python and I would like to authenticate users. The pyrebase package seems to be outdated and it generates dependency errors so I cannot use it. I know that there is a function from the firebase-admin API that works like this:

from firebase import auth
email = example@example.com
user = auth.get_user_by_email(email)

但是如果该用户有密码怎么办?我想检查电子邮件和密码是否正确提供.预先感谢.

But what if this user has a password? I would like to check if the both the email and the password are provided correctly. Thanks in advance.

推荐答案

Firebase Admin SDK不具有当前用户的概念,因此没有API可根据其凭据登录"用户.

The Firebase Admin SDK does not have the concept of a current user, so there's no API to "sign in" a user based on their credentials.

自从构建Web应用程序以来,通常的流程是在客户端代码中使用Firebase JavaScript SDK来将ID令牌从客户端发送到您的服务器上的Python代码,并在该服务器上执行基于用户的操作.

Since you're building a web app, the usual flow is to use the Firebase JavaScript SDK in your client-side code to sign the user in. If needed you can then send the ID token from the client to your Python code on the server, and perform user-based operations there.

这篇关于如何使用Python向Firebase进行身份验证?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆