8000 fix(emulator): add anonymous credentials for emulator · Spirans/firebase-admin-python@76c8cde · GitHub
[go: up one dir, main page]

Skip to content

Commit 76c8cde

Browse files
committed
fix(emulator): add anonymous credentials for emulator
1 parent 59a22b3 commit 76c8cde

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

firebase_admin/storage.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@
2525
raise ImportError('Failed to import the Cloud Storage library for Python. Make sure '
2626
'to install the "google-cloud-storage" module.')
2727

28-
from firebase_admin import _utils
28+
import os
2929

30+
from firebase_admin import _utils
3031

3132
_STORAGE_ATTRIBUTE = '_storage'
3233

@@ -61,7 +62,11 @@ def __init__(self, credentials, project, default_bucket):
6162

6263
@classmethod
6364
def from_app(cls, app):
64-
credentials = app.credential.get_credential()
65+
if os.getenv("STORAGE_EMULATOR_HOST") is not None:
66+
from google.auth.credentials import AnonymousCredentials
67+
credentials = AnonymousCredentials()
68+
else:
69+
credentials = app.credential.get_credential()
6570
default_bucket = app.options.get('storageBucket')
6671
# Specifying project ID is not required, but providing it when available
6772
# significantly speeds up the initialization of the storage client.

0 commit comments

Comments
 (0)
0