tfarras / nestjs-firebase-admin

NestJS Module for Firebase Admin SDK
31 stars 13 forks source link

admin.initializeApp() should be called manually? #1

Closed koko37 closed 4 years ago

koko37 commented 4 years ago

Hello. I am trying to connect firebase , so installed nestjs-firebase-admin into my project. But I am not sure, I have to call admin.initializeApp({credential ...}) manually. I have specified credential, in useFactory(), but it does not work , and showing error message like: "Credential implementation provided to initializeApp() via the credential property failed to fetch a valid Google OAuth2 Access Token ..." Please teach me for this!

var serviceAccount = require(path.resolve(process.env.FIREBASE_CREDENTIAL_PATH));

@Module({
  imports: [
    ConfigModule.forRoot(),
    TypeOrmModule.forRoot(TYPE_ORM_MODULE_OPTIONS),
    FirebaseAdminCoreModule.forRootAsync({
      useFactory: () => ({
          credential: admin.credential.cert(serviceAccount)
      })
    }),
    AuthModule,
    UserModule,
  ],
  controllers: [],
  providers: [],
})