RomainVialard / FirebaseApp

Google Apps Script binding for Firebase Realtime Database
Apache License 2.0
116 stars 30 forks source link
apps-script firebase firebase-realtime-database google-apps-script

FirebaseApp

The Google Apps Script binding for the Firebase Realtime Database

Install

Best it to copy the content of this file in your Google Apps Script project: https://github.com/RomainVialard/FirebaseApp/blob/master/src/Code.gs

You can also add it as a library, though this is not recommended.
https://developers.google.com/apps-script/guides/libraries
Library's script ID: 1VlYLzhwx0YEoxIe62eItLAZeobVt_l-GQUKt2MXXuBHFVsqBkl9C_yBB

Documentation / Reference

Class FirebaseApp

getDatabaseByUrl(url, optSecret)

Retrieves a database by url

encodeAsFirebaseKey(string)

Returns a valid Firebase key from a given string Firebase Keys can't contain any of the following characters: . $ # [ ] / https://firebase.google.com/docs/database/usage/limits#data_tree https://groups.google.com/forum/#!msg/firebase-talk/vtX8lfxxShk/skzA5vQFdosJ

decodeFirebaseKey(string)

Returns a decoded string from a Firebase key encoded by encodeAsFirebaseKey()

signInWithIdp(firebaseConfig, idToken)

Signs in or signs up a user using credentials from an Identity Provider (IdP) - eg: google.com. https://cloud.google.com/identity-platform/docs/reference/rest/v1/accounts/signInWithIdp

Class Database

createAuthToken(userEmail, optAuthData, serviceAccountEmail, privateKey)

Generates an authorization token to firebase

createAuthTokenFromServiceAccount(userEmail, optCustomClaims)

Generates an authorization token to Firebase

createLegacyAuthToken(userEmail, optCustomClaims)

Generates an authorization token to firebase

getData(path, optQueryParameters)

Returns the data at this path

getAllData(requests)

Returns data in all specified paths

pushData(path, data, optQueryParameters)

Generates a new child location using a unique key

setData(path, data, optQueryParameters)

Write data at the specified path

updateData(path, data, optQueryParameters)

Update specific children at the specified path without overwriting existing data

removeData(path, optQueryParameters)

Delete data at the specified path

getUrlFromPath(path)

Gets the absolute URL from the specified path

Tutorials

https://sites.google.com/site/scriptsexamples/new-connectors-to-google-services/firebase/tutorials