Google Cloud authentication failing to find JSON file

I’ve created a serverless api using serverless-http and netlify-lambda. It works! But…
The API makes calls to the Google Cloud Platform. I have a JSON file with the certification details the google-auth library is looking for, and that file name is stored in a .env file at the top of my project.

When running everything locally, and I use Postman to make a server call (localhost:3000/.netlify/functions/server/doSomething) it works as expected.

When deployed to netlify, the same call returns either “Error: Could not load the default credentials. Browse to Autentícate en servicios de Cloud con bibliotecas cliente  |  Autenticación  |  Google Cloud for more information.” or “Error: The file at xxxx.json does not exist, or it is not a file. ENOENT: no such file or directory at /var/task/xxxx.json”

The files are all there in GIT and not excluded. Again, this all works locally like a charm.

  • I’ve made sure the dotenv require is before the google libraries require
  • I’ve tried calling the JSON file from FS to make sure it exists
  • I wrote a js file that is called before the netlify run build which creates the google credentials json file in the places named (not even sure where var/task is…)
  • I’ve included the variables as environment variables in netlify CLI

None of this has had any affect.

Generally, it’s acting like the credentials json file does not exist and refuses to read them.
Please, any help!

Hi @reedloarllc,

We have a Netlify blog post on including files. Could you give that a try and let us know if it works for you?