0
votes

I'm trying to initialize our sdk following the instructions here: https://firebase.google.com/docs/admin/setup#initialize-sdk

Basically, I created a service account and stored the accompanying json for that service account in cloud storage. Great. Now the example says I should reference that Json by:

Set the environment variable GOOGLE_APPLICATION_CREDENTIALS to the file path of the JSON file that contains your service account key

But, we aren't storing the file local to these cloud functions, we are storing it in cloud storage. How do we specify a path to a non-local file?

2

2 Answers

1
votes

The Admin SDK does not support remote configurations. It needs to be local, either on disk or in memory. You will have to write code to download the config from the storage bucket somehow, then feed that to the SDK.

0
votes

In order to initialize the Admin SDK locally (not deployed) you need to download the service account json file and make it accessible by:

  1. Setting an env variable GOOGLE_APPLICATION_CREDENTIALS set to the path "/home/user/serviceaccount.json".

  2. Include the service account file in the functions file and access it via relative path programmatically.

Once deployed the there is a runtime service account [email protected] and the environment variables are already set.