繁体   English   中英

Python 与 FireBase

[英]Python with FireBase

我真的需要帮助,但不确定为什么我的代码没有执行。 我通过阅读不同的解决方案尝试了一切,但没有答案。 所以,我用 Firebase 创建了一个项目。 像往常一样,我设置了一个配置,然后初始化了我的 firebase,并初始化了我的身份验证。 之后,我写了另一行来使用密码创建 user_Credentials email。 由于某种原因,我的 python 没有执行,我真的不知道为什么。

这是我的代码

 # Initializing firebase 
fireBase = pyrebase.initialize_app(firebaseConfig)
authen = fireBase.auth()

# testing 
email = "testing@gmail.com"
password = "123456"

authen.create_user_with_email_and_password(email, password)

错误信息

Traceback (most recent call last):
  File "/Users/kin/Desktop/GitHubRepo/project/client/src/sign_up/authentication.py", line 15, in <module>
    fireBase = pyrebase.initialize_app(firebaseConfig)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pyrebase/pyrebase.py", line 28, in initialize_app
    return Firebase(config)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pyrebase/pyrebase.py", line 36, in __init__
    self.database_url = config["databaseURL"]
KeyError: 'databaseURL'

在此处输入图像描述

您可能尚未在firebaseConfig中为"databaseURL"定义值。

看起来 Pyrebase 仍然需要此密钥存在,这就是您收到错误的原因。

你现在可以做这两件事......

1 - 只需添加一个没有值或虚拟值的键


API_KEY = {
    'apiKey': "##############################",
    'authDomain': "********************",
    'projectId': "&&&&&&&&&&&",
    'storageBucket': "************",
    'messagingSenderId': "*************",
    'appId': "***************",
    'measurementId': "************",
    'databaseURL': ""
}

2 - 从此处添加您的 firebase 帐户中的 databaseURL

API_KEY = {
        'apiKey': "##############################",
        'authDomain': "********************",
        'projectId': "&&&&&&&&&&&",
        'storageBucket': "************",
        'messagingSenderId': "*************",
        'appId': "***************",
        'measurementId': "************",
        'databaseURL': "link of your databaseURL"
}

好吧, Pyrebase已经存在一个针对此问题的问题,可以随意解决此问题。

暂无
暂无

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

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