Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

KeyError: 'databaseURL' while Firebase Authentication in Python

Trust you are doing well. I am new to firebase and trying to do user authentication. I have installed pyrebase4 and created a project on the firebase console. I also enabled sign in with "Email and Password" and trying to connect with my app. Below is my code that I am trying:

    import pyrebase

#connect to firebase via key-value pair
firebaseConfig = {
    "apiKey": "xxxxxxxxxxxxxxxxxx",
    "authDomain": "xxxxxxxxxxx",
    "projectId": "xxxxxxxxxxx",
    "storageBucket": "xxxxxxxxxxxxxx",
    "messagingSenderId": "xxxxxxxxxxxxx",
    "appId": "xxxxxxxxxxxxxxxxxxxx",
    "measurementId": "G-5GCDEC526E"
}

#initialize the app
firebase = pyrebase.initialize_app(firebaseConfig)

#connect to firebase database
#db = firebase.database()
auth = firebase.auth()
#storage = firebase.storage()

#user login authentication
email = input("Enter your email: \n")
password = input("Enter your password: \n")
user = auth.create_user_with_email_and_password(email, password)
auth.get_account_info(user['idToken'])

I am using VS Code as an IDE, Python 3.8, and Ubuntu OS. Below is the error I am getting:

python3 main.py
Traceback (most recent call last):
  File "main.py", line 15, in <module>
    firebase = pyrebase.initialize_app(firebaseConfig)
  File "/home/sonu/.local/lib/python3.8/site-packages/pyrebase/pyrebase.py", line 28, in initialize_app
    return Firebase(config)
  File "/home/sonu/.local/lib/python3.8/site-packages/pyrebase/pyrebase.py", line 36, in __init__
    self.database_url = config["databaseURL"]
KeyError: 'databaseURL'

Can you help me solve the issue? Thanks in advance.

like image 223
Sonu Kumar Avatar asked Oct 13 '25 00:10

Sonu Kumar


1 Answers

As the error said. The databaseURL property is missing from your configuration.

Since now the Realtime Database is not automatically be created at the time you create the new firebase project so the databaseURL is not included by default. See also

like image 64
Siratee K. Avatar answered Oct 14 '25 12:10

Siratee K.