Unknown
Unknown

Reputation: 423

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

Upvotes: 6

Views: 7187

Answers (1)

Frank van Puffelen
Frank van Puffelen

Reputation: 598797

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.

Upvotes: 13

Related Questions