I am using firebase-admin with python to access storage buckets and it works fine with my real project. But now I want to connect it to the firebase emulator instead of a real bucket.
I looked at the docs here: https://firebase.google.com/docs/emulator-suite/connect_storage#admin_sdks and I have already added the FIREBASE_STORAGE_EMULATOR_HOST environment variable like this:
export FIREBASE_STORAGE_EMULATOR_HOST="localhost:9199"
Now I wanted to use the fake emulated storage bucket instead of the real one and this is the code I have so far:
from firebase_admin import storage
from firebase_admin import credentials
cred = credentials.Certificate('key.json')
default_app = firebase_admin.initialize_app(cred)
bucket = storage.bucket("<project_id>.appspot.com") # what am I supposed to put here
With this code it just uses the real firebase storage bucket.
I have also tried putting 127.0.0.1:9199
as the bucket name, but it gives the following error:
google.api_core.exceptions.NotFound: 404 GET https://storage.googleapis.com/storage/v1/b/127.0.0.1:9199/o?projection=noAcl&prettyPrint=false: The specified bucket does not exist.
Try to set env like this:
STORAGE_EMULATOR_HOST=http://localhost:9199
Worked for me