Open
Description
This is on the emulator with v0.1.1. I have not tested this as a deployed function.
Not sure if this is my mistake, but I can't seem to access the secrets from within a Firestore function, although the secrets parameter looks like it is defined in _GLOBAL_OPTIONS?
from firebase_functions import firestore_fn
from firebase_admin import initialize_app, firestore
from firebase_functions.params import SecretParam
app = initialize_app()
db = firestore.client()
SECRET_KEY_ONE = SecretParam("SECRET_KEY_ONE")
SECRET_KEY_TWO = SecretParam("SECRET_KEY_TWO")
@firestore_fn.on_document_created(document="Chat/{chatId}", secrets=[SECRET_KEY_ONE, SECRET_KEY_TWO])
def onChatCreated(
event: firestore_fn.Event[firestore_fn.DocumentSnapshot | None]
) -> None:
print(SECRET_KEY_ONE.value())
return
Gives me
TypeError: 'str' object is not callable
When I change the code to
print(SECRET_KEY_ONE)
it gives me {{ params.SECRET_KEY_ONE }}
The secrets are defined in Cloud Secrets. When I change the secrets' names, it asks me to save a new value, indicating that it is aware of their existence of their original names in Cloud Secrets.