Skip to content
This repository has been archived by the owner on Oct 17, 2024. It is now read-only.

Not working with firebase 10 #525

Open
RoyBkker opened this issue Dec 15, 2021 · 7 comments
Open

Not working with firebase 10 #525

RoyBkker opened this issue Dec 15, 2021 · 7 comments

Comments

@RoyBkker
Copy link

When updating to firebase 10, I receive errors that initializing is not working anymore.

import { FirebaseAdminModule } from '@aginix/nestjs-firebase-admin';
import { Module } from '@nestjs/common';
import { join } from 'path';
import { cert } from 'firebase-admin/app';

// eslint-disable-next-line @typescript-eslint/no-var-requires
const serviceAccount = require(join(
  __dirname,
  `config/firebase-admin-${process.env.FIREBASE_ENV}.json`,
));

console.log(serviceAccount);

@Module({
  imports: [
    FirebaseAdminModule.forRootAsync({
      useFactory: () => ({
        credential: cert(serviceAccount),
      }),
    }),
  ],
})
export class FirebaseModule {}

ERROR
Failed to determine project ID for Auth. Initialize the SDK with service account credentials or set project ID as an app option.

@DavidAmunga
Copy link

Also experiencing the same issue.

@Bahad001
Copy link

Bahad001 commented Feb 6, 2022

Also experiencing the same issue.

Same thing here, did you fix it?

@shahkeyur
Copy link

Same for me. @n3n Would you have to time to fix this issue?

@gaetansenn
Copy link

Look's like it's not maintained anymore

@jeremytsngtsng
Copy link

You need to include projectId in useFactory

FirebaseAdminModule.forRootAsync({
      useFactory: () => ({
        credential: admin.credential.cert({
          private_key: process.env.FIREBASE_PRIVATE_KEY,
          client_email: process.env.FIREBASE_CLIENT_EMAIL,
          project_id: process.env.FIREBASE_PROJECT_ID,
          google_cloud_project: process.env.FIREBASE_PROJECT_ID,
        } as Partial<admin.ServiceAccount>),
        projectId: process.env.FIREBASE_PROJECT_ID,
        databaseURL: process.env.FIREBASE_DATABASE_URL,
      }),
    }),

@younes0
Copy link

younes0 commented Nov 26, 2022

@jeremytsngtsng your solution doesn't work

Problem is that this lib will install its own firebase-admin package (v9).
To avoid it, add to your package.json

  "resolutions": {
    "firebase-admin": "^11.3.0"
  },

@kyle-seongwoo-jun
Copy link

  "resolutions": {
    "firebase-admin": "^11.3.0"
  },

@younes0 this is works so perfectly! You saved me, Thank you 👍

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants