简体   繁体   English

Python 与 FireBase

[英]Python with FireBase

I really need help and am not sure why my code is not executing.我真的需要帮助,但不确定为什么我的代码没有执行。 I tried everything by reading different solution and there was no answer.我通过阅读不同的解决方案尝试了一切,但没有答案。 so, I created a project with Firebase.所以,我用 Firebase 创建了一个项目。 As usual, i set up a config, and then initialized my firebase, and initialized my auth.像往常一样,我设置了一个配置,然后初始化了我的 firebase,并初始化了我的身份验证。 After that, i wrote another line to create user_Credentials email with password.之后,我写了另一行来使用密码创建 user_Credentials email。 For some reason my python is not executing and I really dunno why.由于某种原因,我的 python 没有执行,我真的不知道为什么。

Here is my code这是我的代码

 # 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)

Error message错误信息

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'

在此处输入图像描述

You probably have not defined a value for "databaseURL" in your firebaseConfig .您可能尚未在firebaseConfig中为"databaseURL"定义值。

It looks like Pyrebase still requires this key to exist though, which is why you get an error.看起来 Pyrebase 仍然需要此密钥存在,这就是您收到错误的原因。

You can do this two things for now....你现在可以做这两件事......

1 - Just add a key with no value, or a dummy value 1 - 只需添加一个没有值或虚拟值的键


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

2 - Add the databaseURL from Your firebase account from here 2 - 从此处添加您的 firebase 帐户中的 databaseURL

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

well there was an issue already open at Pyrebase which target to this problem, fell free to solve this issue.好吧, Pyrebase已经存在一个针对此问题的问题,可以随意解决此问题。

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

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