Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Accessing Firebase admin from google cloud functions

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

like image 509
Unknown Avatar asked Sep 01 '26 07:09

Unknown


1 Answers

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.

like image 179
Frank van Puffelen Avatar answered Sep 02 '26 20:09

Frank van Puffelen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!