Problem
When connecting to a 3rd party storage emulator, like gcloud-storage-emulator, authentication is required. This requires injecting credentials into containers and adding conditional logic in code to authenticate when running against emulators.
import os
from firebase_admin import initialize_app, storage
os.environ['STORAGE_EMULATOR_HOST'] = 'http://localhost:9090'
assert 'GOOGLE_APPLICATION_CREDENTIALS' not in os.environ
initialize_app()
storage.bucket() # google.auth.exceptions.DefaultCredentialsError
Solution
When STORAGE_EMULATOR_HOST is set, use an insecure connection, as is done for firestore.
Problem
When connecting to a 3rd party storage emulator, like
gcloud-storage-emulator, authentication is required. This requires injecting credentials into containers and adding conditional logic in code to authenticate when running against emulators.Solution
When
STORAGE_EMULATOR_HOSTis set, use an insecure connection, as is done forfirestore.