Firebase Cloud Function config to access other project db

Viewed 2517

I need to create a Cloud Function that will access the Firebase DB that is running in another project. If it was accessing the db in the current project, I could use code such as

const functions = require('firebase-functions');

const admin = require('firebase-admin');
admin.initializeApp(functions.config().firebase);

however, what I want is for functions.config().firebase to return the information (and, most importantly, credentials) for the other project. Is there any easy way to do this?

2 Answers

instead of

if (!functions.config().app || !functions.config().app.project_id) {

You should use

if (!functions.config().app || !functions.config().app.fb_project_id) {

NOTE: the typo in project_id

Related