Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Firebase.init() throws error when JSON config has no databaseURL key #57

Open
phlummox opened this issue Jan 2, 2023 · 2 comments
Open

Comments

@phlummox
Copy link

phlummox commented Jan 2, 2023

Make sure these boxes are checked before submitting your issue:

[x] Check that your version of Python is 3.4+
[x] Check that you are on the newest version of Pyrebase
[x] Check that Email/password provider is enabled in your Firebase dashboard under Auth -> Sign In Method.

At least on my current Firebase project, the JSON configuration got from the Firebase console has no "databaseURL" key.

Instead, the keys are:

{
 "apiKey": ...,
 "authDomain": ...,
 "projectId": ...,
 "storageBucket": .,
 "messagingSenderId": ...,
 "appId": ...,
 "measurementId": ...
}

That means that the following line of pyrebase.Firebase.__init__ throws an exception:

self.database_url = config["databaseURL"]

The fix seems to be to replace that line with the following code

        if "databaseURL" in config:
          self.database_url = config["databaseURL"]

but I don't know if that has knock-on consequences elsewhere in the codebase.

phlummox added a commit to phlummox-mirrors/Pyrebase4 that referenced this issue Jan 2, 2023
@AsifArmanRahman
Copy link

At least on my current Firebase project, the JSON configuration got from the Firebase console has no "databaseURL" key.

In previous days, the databaseURL key came by default in the firebase configuration json. The library still follows that pattern, and it makes sense to so, because it'll enable usage of all sub-modules at once.

I maintain a version of pyrebase/pyrebase4 repo, and in the documentation for that project, I've mentioned about the key here.

@Strain-solutions
Copy link

Strain-solutions commented May 16, 2023

Coming across the same issue I came across a SO post that the URL is no longer needed to authenticate. So I passed None for both databaseURL and storageBucket (since Im not using cloud storage and Im using firestore not the RTB). I could authenticate just fine.

config = {
  "apiKey": "myAPIKeyGoesHere",
  "authDomain": "myFIrebaseAPP.firebaseapp.com",
  "databaseURL":None,
  'storageBucket':None,
}

firebase = pyrebase.initialize_app(config)

auth = firebase.auth()

user = auth.sign_in_with_email_and_password('[email protected]', '123456789')
print(user)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants