firebase / firebase-admin-go

Firebase Admin Go SDK
Apache License 2.0
1.12k stars 239 forks source link

FR: Allow JSON string to be passed to GOOGLE_APPLICATION_CREDENTIALS #598

Open lordvidex opened 7 months ago

lordvidex commented 7 months ago

In order to use this library to send push notifications, it is necessary to pass the services_account.json file path to the environment variable GOOGLE_APPLICATION_CREDENTIALS. However, allowing the JSON string to be passed directly will also help for certain scenarios where the the secret do not necessary exist in a file.

In fact, the firebase_config is parsed this way.

For example:

secret := someSecretStore.Get("GOOGLE_CREDS")
os.Setenv("GOOGLE_APPLICATION_CREDENTIALS", secret)
...
# initialize firebase App