The Google Apps Script binding for the Firebase Realtime Database
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
Retrieves a database by url
- Parameters:
-
urlβstringβ - the database url -
[optSecret]βstringβ - a Firebase app secret
-
- Returns:
Databaseβ the Database found at the given URL
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
-
Parameters:
stringβstringβ - the string to encode -
Returns:
stringβ the encoded string
Returns a decoded string from a Firebase key encoded by encodeAsFirebaseKey()
-
Parameters:
stringβstringβ - the encoded Firebase key -
Returns:
stringβ the decoded string
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
- Parameters:
-
firebaseConfigβobjectβ - see the "Get config object for your web app" section in the page linked below. -
idTokenβstringβ - an OpenID Connect identity token retrieved via ScriptApp.getIdentityToken()
-
- Returns:
objectβ the auth token granting access to firebase
Generates an authorization token to firebase
- Parameters:
userEmailβstringβ the email account of the user you want to authenticateoptAuthDataβobjectβ key-pairs of data to be associated to this user.serviceAccountEmailβstringβ the email of the service account used to generate this tokenprivateKeyβstringβ the private key of this service account
- Returns:
objectβ the auth token granting access to firebase
Generates an authorization token to Firebase
- Parameters:
-
userEmailβstringβ - the email account of the user you want to authenticate -
optCustomClaimsβobjectβ - key-pairs of data to be associated to this user (aka custom claims).
-
- Returns:
objectβ the auth token granting access to firebase
Generates an authorization token to firebase
- Parameters:
userEmailβstringβ the email account of the user you want to authenticateoptCustomClaimsβobjectβ - key-pairs of data to be associated to this user (aka custom claims).
- Returns:
objectβ the auth token granting access to firebase
Returns the data at this path
- Parameters:
-
pathβstringβ - the path where the data is stored -
[optQueryParameters]βOptQueryParametersβ - a set of query parameters
-
- Returns:
objectβ the data found at the given path
Returns data in all specified paths
-
Parameters:
{Array.<stringβ FirebaseApp_.request>} requests - array of requests -
Returns:
objectβ responses to each requests
Generates a new child location using a unique key
- Parameters:
-
pathβstringβ - the path where to create a new child -
dataβobjectβ - the data to be written at the generated location -
[optQueryParameters]βOptQueryParametersβ - a set of query parameters
-
- Returns:
stringβ the child name of the new data that was added
Write data at the specified path
- Parameters:
-
pathβstringβ - the path where to write data -
dataβobjectβ - the data to be written at the specified path -
[optQueryParameters]βOptQueryParametersβ - a set of query parameters
-
- Returns:
objectβ the data written
Update specific children at the specified path without overwriting existing data
- Parameters:
-
pathβstringβ - the path where to update data -
dataβobjectβ - the children to overwrite -
[optQueryParameters]βOptQueryParametersβ a - set of query parameters
-
- Returns:
objectβ the data written
Delete data at the specified path
- Parameters:
-
pathβstringβ - the path where to delete data -
[optQueryParameters]βOptQueryParametersβ - a set of query parameters
-
- Returns:
nullβ
Gets the absolute URL from the specified path
- Parameters:
pathβstringβ - the path / location to convert to URL - Returns:
stringβ an encoded URL that is ready to be put into a browser
#Tutorials https://sites.google.com/site/scriptsexamples/new-connectors-to-google-services/firebase/tutorials