简体   繁体   中英

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. As usual, i set up a config, and then initialized my firebase, and initialized my auth. After that, i wrote another line to create user_Credentials email with password. For some reason my python is not executing and I really dunno why.

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 .

It looks like Pyrebase still requires this key to exist though, which is why you get an error.

You can do this two things for now....

1 - Just add a key with no value, or a dummy value


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

2 - Add the databaseURL from Your firebase account from here

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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