const admin = require('firebase-admin');
require('dotenv').config()
// const serviceAccount = require("../service-account-file.json");
const check = process.env.GOOGLE_APPLICATION_CREDENTIALS;
//GOOGLE_APPLICATION_CREDENTIALS="/home/byordani93/tuDiagram/service-account-file.json"
console.log(check, 'mate')
admin.initializeApp({
projectId: 'tudiagram',
credential: admin.credential.applicationDefault(check),
databaseURL: 'https://tudiagram.firebaseio.com'
});
module.exports = admin;
then msg
> (node:3218) UnhandledPromiseRejectionWarning: Error: Credential
> implementation provided to initializeApp() via the "credential"
> property failed to fetch a valid Google OAuth2 access token with the
> following error: "Error fetching access token: Error while making
> request: The "options.agent" property must be one of type Agent-like
> Object, undefined, or false. Received type string. Error code:
> ERR_INVALID_ARG_TYPE".
>
I tried making the env value a string and not a string as well as checking to see if the process.env was being detected and still nothing not sure at this point I have googled to no avail please give some pointers or tips **hint hint maybe a solution haha :)
Try this one
import * as firebase from 'firebase-admin';
const serviceAccount = require("../../serviceAccountKey.json")
firebase.initializeApp({
credential: firebase.credential.cert(serviceAccount),
databaseURL: 'https://xxxxxx.firebaseio.com'
});
changing the applicationDefault to cert
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With