Invalid parent project. Either parent project doesn't exist or didn't enable multi-tenancy

18 views Asked by At

I have node.js as back-end, there I use firebase and firebase-admin. when I use firebase-admin configuration like that:

import admin from "firebase-admin";
import { cert } from "firebase-admin/app";

const Service = require("../adminSDK_service.json");

const { PRIVATE_KEY, PROJECT_ID, CLIENT_EMAIL } = process.env;

const fireBase_Admin = admin.initializeApp({
  credential: cert(Service),
  databaseURL: process.env.DATA_BASE_URL,
});

export default fireBase_Admin;

here everything is fine but problem is that I don't know where I can save json file to be secured.

I know way to resolve this problem, I mean make github repository private, but I build this project for my portfolio so I want to be visible for everyone. then I read documentation of "cert" function and as I got there we need only three arguments:

  1. projectId 2) clientEmail 3) privateKey

import admin from "firebase-admin";
import { cert } from 'firebase-admin/app'

const Service = require("../adminSDK_service.json");

const { PRIVATE_KEY, PROJECT_ID, CLIENT_EMAIL } = process.env;

const fireBase_Admin = admin.initializeApp({
  credential: cert({
    privateKey: PRIVATE_KEY?.replace(/\\n/g, "\n"),
    projectId: PROJECT_ID,
    clientEmail: CLIENT_EMAIL,
  }),
  databaseURL: process.env.DATA_BASE_URL,
});

export default fireBase_Admin;

And I set the values there from env, but when I try to sign In. I get the error:

Invalid parent project. Either the parent project doesn't exist or didn't enable multi-tenancy.

in the sign-in function, I try to get the user to check if such a user exists like that:

// find user
const user = await Admin.auth().getUserByEmail(email);

console.log(user);

if (!user) {
  return {
    status: false,
    message: "error!",
  };
}

and when I remove it, works everything fine... so..

so I am confused if "cert" requires only three arguments this means it uses three values from the JSON file yes?

I also heard about Google Secret Manager but I don't understand how I can use it, if you have any source or video tutorial please write in the comment

I have hope you will help me.

0

There are 0 answers