Jim
Jim

Reputation: 2322

How to set an environment variable for google credentials in a heroku app

Im using heroku to host an express server that uses firebase-admin to update firestore data.

Google docs say:

When authorizing via a service account, you have two choices for providing the credentials to your application. You can either set the GOOGLE_APPLICATION_CREDENTIALS environment variable, or you can explicitly pass the path to the service account key in code. The first option is more secure and is strongly recommended.

To set the environment variable:

Set the environment variable GOOGLE_APPLICATION_CREDENTIALS to the file path of the JSON file that contains your service account key. This variable only applies to your current shell session, so if you open a new session, set the variable again.

I have the JSON file with the service account key downloaded locally. and google says to avoid passing the path to the service account key in code. so how do you actually "set the GOOGLE_APPLICATION_CREDENTIALS environment variable" for a node.js project running on heroku server? Some details that help elucidate how this works would also be appreciated. How is a local file supposed to be accessed from a remote server, why a path isn't secure etc

Upvotes: 1

Views: 2378

Answers (1)

AlTheLazyMonkey
AlTheLazyMonkey

Reputation: 1242

Try to go in your account -> project -> settings and like second voice there is Config Vars.

Press on Reveal Config Vars. Here you can insert the GOOGLE_APPLICATION_CREDENTIALS variable.

Upvotes: 1

Related Questions