简体   繁体   English

如何连接 Firebase Auth 模拟器和 Python

[英]How to Connect Firebase Auth Emulator With Python

i am new to python and trying to figure out how to connect my auth emulator with python project.我是 python 的新手,正在尝试弄清楚如何将我的 auth 模拟器与 python 项目连接起来。 Actually, i want to create the users on emulator but when i create a user it is created on my real time firebase project实际上,我想在模拟器上创建用户,但是当我创建一个用户时,它是在我的实时 firebase 项目上创建的

  • I have ini the firebase project in my python project我在我的 python 项目中有 firebase 项目
  • I have exported the following environment variable export FIREBASE_AUTH_EMULATOR_HOST="localhost:9099" from terminal and also set the os.env from my file but nothing worked for me我已经从终端导出了以下环境变量export FIREBASE_AUTH_EMULATOR_HOST="localhost:9099"并且还从我的文件中设置了os.env但对我没有任何作用
  • I also used the method provided by pyrebase create_user_with_email_and_password for creating a user but this creates the user on firebase real project The image of what i have done so far is here我还使用了 pyrebase create_user_with_email_and_password提供的方法来创建用户,但这会在 firebase 真实项目上创建用户我到目前为止所做的图像在这里

If anyone knows the solution please let me know it will be very grateful for me!如果有人知道解决方案,请告诉我,我将非常感激!

In case this helps someone else, this is how I managed to connect and use the auth emulator in python:如果这对其他人有帮助,这就是我在 python 中设法连接和使用身份验证模拟器的方式:

# Import auth from firebase admin
from firebase_admin import auth

# Set the auth emulator environment variable to the correct port, as shown when starting up the emulator.

if USE_EMULATOR == 'True':
  os.environ["FIREBASE_AUTH_EMULATOR_HOST"] = "127.0.0.1:9099"


user = auth.create_user(email=email, password=password )

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM