[英]Authentication with firestore in python using firebase_admin
I am using firestore in python with firebase_admin and want to access the authentication module of firebase.我在 python 中使用 firestore 和 firebase_admin 并想访问 firebase 的身份验证模块。 I have created data in authentication with auth.create_user() by importing auth from firebase_admin.我通过从 firebase_admin 导入 auth 使用 auth.create_user() 创建了身份验证数据。
import firebase_admin
from firebase_admin import credentials
from firebase_admin import firestore, auth
cred = credentials.Certificate("servicesAccountKey.json")
firebase_admin.initialize_app(cred)
db = firestore.client()
# <<<<<<<<<<<<<<<<<<<<******************** SignUp ********************>>>>>>>>>>>>>>>>>>>>
def signUp(userObject):
user = userObject.getUser()
auth.create_user(uid=user['cnic'], email=user['email'], password=user['password']) "
Now I want to authenticate for signIn but not able to find module auth.sign_in_with_email_and_password.现在我想对登录进行身份验证,但找不到模块 auth.sign_in_with_email_and_password。 This module is available with realtime database which connects with pyerbase but not in firestore connected with firebase_admin.该模块可用于与 pyerbase 连接的实时数据库,但不能在与 firebase_admin 连接的 firestore 中使用。
def signIn(cnic,password):
auth.sign_in_with_email_and_password(cnic, password)
I can use auth with pyrebase but i have to import pyrebase and firebase_admin both which i dont want it.我可以将 auth 与 pyrebase 一起使用,但我必须导入我不想要的 pyrebase 和 firebase_admin。 Is any module available for firebase_admin for authentication to signIN? firebase_admin 是否有任何模块可用于登录身份验证?
The Admin SDKs for Firebase run with elevated, administrative privileges, and don't have any capability to sign in a user. Firebase 的管理 SDK 以提升的管理权限运行,并且没有任何登录用户的能力。
You may want to consider your use-case: if you ship the administrative credentials (that the Admin SDK needs/uses) to your regular users they have full access to your Firebase and Google Cloud project.您可能需要考虑您的用例:如果您将管理凭据(管理员 SDK 需要/使用)发送给您的普通用户,他们就可以完全访问您的 Firebase 和 Google Cloud 项目。 You'll want to separate the administrative functionality of your app from the end-user functionality, and use either the REST SDK or a client-side SDK (like Pyrebase) for the end-user app.您需要将应用程序的管理功能与最终用户功能分开,并使用 REST SDK 或客户端 SDK 应用程序。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.