My FeedDiscussionsHeadless CMS
New
Sign in
Log inSign up
Learn more about Hashnode Headless CMSHashnode Headless CMS
Collaborate seamlessly with Hashnode Headless CMS for Enterprise.
Upgrade ✨Learn more

Issues with env variables not being parsed properly

Emmanuel's photo
Emmanuel
·Oct 24, 2018

I'm using the firebase-admin for Nodejs. Below is what my firebase config.json file looks like. I'm using the dotenv npm package to parse my env variables.

{
  "type": "process.env.FIREBASE_POJECT_TYPE",
  "project_id": "process.env.FIREBASE_PROJECT_ID",
  "private_key_id": "process.env.FIREBASE_PRIVATE_KEY_ID",
  "private_key": "process.env.FIREBASE_PRIVATEKEY",
  "client_id": "process.env.FIREBASE_CLIENT_ID",
  "auth_uri": "process.env.FIREBASE_AUTH_URI",
  "token_uri": "process.env.FIREBASE_TOKEN_URI",
  "auth_provider_x509_cert_url": "process.env.FIREBASE_AUTH_PROVIDER_X509_CERT_URL",
  "client_x509_cert_url": "process.env.FIREBASE_CLIENT_X509_CERT_URL",
  "client_email": "process.env.FIREBASE_CLIENT_EMAIL"
}

The weird thing is all the env variables above, except the private_key and the client_email variables, are parsed properly; I'm not sure why this is. Please, has anyone here experienced this? What could be the issue?

It's even strange because when I console.log the values, I get them all, none of them is undefined, so why firebase isn't understanding the request and giving me this error

{ code: 'app/invalid-credential',
     message: 'Credential implementation provided to initializeApp() via the "credential" property failed to fetch a valid Google OAuth2 access token with the following error: "Failed to parse access token response: Error: Server responded with status 400.".' },

is quite perplexing.

Pointers are greatly appreciated...