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 Function with python. Data Are not written to The Firebase Emulator #115

Open
BrightX0 opened this issue Jul 5, 2023 · 2 comments
Labels
waiting for customer response Issue is on hold awaiting more information from OP

Comments

@BrightX0
Copy link

BrightX0 commented Jul 5, 2023

Hi Folks. So I am Having issues Connecting the local firebase emulator with python firebase functions.recently i was trying to migrate my javascript code to python to leverage the python libraries and its ecosystem. If i use a Callable function in javascript to write data to the firebase with firebase Admin privilege it does so, but when i am trying to use with python, The Callable function gets called but if use the firebase Admin package to write data to the firestore the data are not written. is there Anything that I am Missing?
MacOS Ventura with Python 3.11 and venv.

@russellwheatley
Copy link
Member

Hey @BrightX0, could you provide a code sample of how you've implemented the function, please?

@russellwheatley russellwheatley added the waiting for customer response Issue is on hold awaiting more information from OP label Jul 10, 2023
@ekalosak
Copy link
Contributor

ekalosak commented Sep 11, 2023

Make sure you have:

from firebase_admin import initialize_app
from firebase_admin.firestore import firestore

initialize_app()
db = firestore.Client(project=GCLOUD_PROJECT)

at the very top.

These two are both vital:

  1. initialize_app is in the docs and you are probably already doing this.
  2. Setting your GCLOUD_PROJECT explicitly is important, you might not be doing this.

When you start the emulator, make sure you use the -p <GCLOUD_PROJECT> arg. The default project name is something like firebase-default-emulator-project. Your default project name in the Python SDK will be plucked from your gcloud environment credentials. In my case, when the project names were mismatched, I'd get a lot of silent "failures" to write data - it was just that the data were being written to the wrong project namespace's default firebase.

EDIT: I should add, I'm using MacOS Monterey and Python 3.11.4 with venv.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
waiting for customer response Issue is on hold awaiting more information from OP
Projects
None yet
Development

No branches or pull requests

3 participants