如何使用Python对Firebase进行身份验证?

时间:2019-11-03 00:50:05

标签: python firebase firebase-authentication firebase-admin

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

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

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

1 个答案:

答案 0 :(得分:1)

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

自从构建Web应用程序以来,通常的流程是在sign the user in的客户端代码中使用Firebase JavaScript SDK。如果需要,您可以send the ID token from the client to your Python code on the server,并在那里执行基于用户的操作。