I am trying to access and update my firebase database from GOOGLE cloud function but it is not working.

I have written a cloud function in which I have initialized firebase-admin.

I have to provide service_account to initialize admin.

I am initializing my firebase app as

admin.initializeApp({
   credential: admin.credential.cert(service_account),
  databaseURL: "",
  databaseAuthVariableOverride: {
    uid: ""
  }
});

I don't have my service account path in GOOGLE cloud functions.

Is there any method to access firebase from GOOGLE cloud functions?

Thanks

1 Answers

1
Frank van Puffelen On Best Solutions

Within Google Cloud Functions the required configuration data can be looked up automatically, so you don't have to provide configuration data for the Firebase Admin SDK.

All that is needed in most cases is:

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

admin.initializeApp();

Also see the documentation section Import the required modules and initialize an app.