Getting Started

Import Firefast library and use your service account to connect with your Firebase database

Follow these steps to get started:

1. Open your script editor and click on Resources > Libraries

Import Firefast library and use your service account to connect with your Firebase database

2. In the "Add a library" textbox, enter the Script ID "18XQQ44n7ineBH4-nwzxMu-uC9bywPhpzDlfrON9aLd13AHOxkGR9MlFe" and click "Add". Once it is added to the list of Libraries, select the latest version of "firebase" and click "Save".

Import Firefast library and use your service account to connect with your Firebase database

3. Open your Firebase database in the Firebase Console and click on "Project settings"

Import Firefast library and use your service account to connect with your Firebase database

4. Once you are in "Settings", click on "Service accounts" tab > click on "Generate new private key" button. You should be able to download a JSON file.

Import Firefast library and use your service account to connect with your Firebase database

5. Copy/paste the below code inside your function in apps script editor:

var serviceAccount = {... Service Account JSON goes here ...};
firebase.initializeApp({
credential: firebase.credential.cert(serviceAccount),
databaseURL: "https://yourproject.firebaseio.com"
});
firebase.database().ref("/some_resource").once("value").then(snap=>{
Logger.log(snap.val());
});

6. Run the project after making these changes:

- Replace {... Service Account JSON goes here ...} with the JSON from the downloaded file
- Replace "https://yourproject.firebaseio.com" with your database url.
- Replace "/some_resource" with the one that exists in your database.

You should be able to see the retrieved data in "View" > "Logs"