Addding Google Cloud Application Default Credentials to App

PLEASE help us help you by writing a good post!

My current deployment doesn’t have an environment variable GOOGLE_APPLICATION_CREDENTIALS which points to a JSON file that contains the Service Account Key.

I’m needing assistance on how to setup this environment variable such that it can access the file in the deployed version of the site.

I have had no issues locally due to the gcloud CLI using a application_default_credentials.json in it’s config, but I am at a loss on how to include this in a production build such that it can be called by a google client application library.

As for my use-case, I’m looking to use reCAPTCHA v3, and it requires authentication to use their client library, is this at all possible?

Are you comitting the file to your repo? If yes, you can refer to: How to Include Files in Netlify Serverless Functions

If not, you’d have to add each value seperately as an environment variable and generate the JSON file on the fly. You can then write that file to the /tmp dir and point the library to that.