简体   繁体   English

使用 firebase_admin 在 python 中使用 firestore 进行身份验证

[英]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.

相关问题 python 中的 Firestore 客户端(作为用户)使用 firebase_admin 或 google.cloud.firestore - Firestore client in python (as user) using firebase_admin or google.cloud.firestore "连接到 Firestore 模拟器时 Python firebase_admin 挂起" - Python firebase_admin hangs when connecting to firestore emulator 如何在 Python 中使用 firebase_admin 提及凭据的正确路径? - How to mention correct path for credentials using firebase_admin in Python? 如何在 python 上调试 firebase_admin - How to debug firebase_admin on python Firestore AttributeError:模块“firebase_admin”没有属性“firestore” - Firestore AttributeError: module 'firebase_admin' has no attribute 'firestore' firebase_admin python 库“没有这样的文件或目录” - “No such file or directory” with firebase_admin python library 如何使用带有 get() 的 firebase_admin 查询 firestore 文档 - How do I query a firestore document using firebase_admin with get() 使用 python 中的 firebase_admin 连接到 firebase 仿真器的凭据是什么? - What credentials to use to connect to firebase emulator using firebase_admin in python? 如何使用 firebase_admin 从 python 中的 firebase 存储中下载文件 - How to download file from firebase storage in python using firebase_admin 实时事件可以监听firebase_admin firestore吗? - is realtime event listening for firebase_admin firestore possible?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM