Giter VIP home page Giter VIP logo

firebaseapp's Introduction

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

  • Parameters:
    • urlstring — - the database url

    • [optSecret]string — - a Firebase app secret

  • Returns: Database — the Database found at the given 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

  • Parameters: stringstring — - the string to encode

  • Returns: string — the encoded string

decodeFirebaseKey(string)

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

  • Parameters: stringstring — - the encoded Firebase key

  • Returns: string — the decoded string

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

  • Parameters:
  • Returns: object — the auth token granting access to firebase

Class Database

createAuthToken(userEmail, optAuthData, serviceAccountEmail, privateKey)

Generates an authorization token to firebase

  • Parameters:
    • userEmailstring — the email account of the user you want to authenticate
    • optAuthDataobject — key-pairs of data to be associated to this user.
    • serviceAccountEmailstring — the email of the service account used to generate this token
    • privateKeystring — the private key of this service account
  • Returns: object — the auth token granting access to firebase

createAuthTokenFromServiceAccount(userEmail, optCustomClaims)

Generates an authorization token to Firebase

  • Parameters:
    • userEmailstring — - the email account of the user you want to authenticate

    • optCustomClaimsobject — - key-pairs of data to be associated to this user (aka custom claims).

  • Returns: object — the auth token granting access to firebase

createLegacyAuthToken(userEmail, optCustomClaims)

Generates an authorization token to firebase

  • Parameters:
    • userEmailstring — the email account of the user you want to authenticate
    • optCustomClaimsobject — - key-pairs of data to be associated to this user (aka custom claims).
  • Returns: object — the auth token granting access to firebase

getData(path, optQueryParameters)

Returns the data at this path

  • Parameters:
    • pathstring — - the path where the data is stored

    • [optQueryParameters]OptQueryParameters — - a set of query parameters

  • Returns: object — the data found at the given path

getAllData(requests)

Returns data in all specified paths

  • Parameters: {Array.<string — FirebaseApp_.request>} requests - array of requests

  • Returns: object — responses to each requests

pushData(path, data, optQueryParameters)

Generates a new child location using a unique key

  • Parameters:
    • pathstring — - the path where to create a new child

    • dataobject — - 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

setData(path, data, optQueryParameters)

Write data at the specified path

  • Parameters:
    • pathstring — - the path where to write data

    • dataobject — - the data to be written at the specified path

    • [optQueryParameters]OptQueryParameters — - a set of query parameters

  • Returns: object — the data written

updateData(path, data, optQueryParameters)

Update specific children at the specified path without overwriting existing data

  • Parameters:
    • pathstring — - the path where to update data

    • dataobject — - the children to overwrite

    • [optQueryParameters]OptQueryParameters — a - set of query parameters

  • Returns: object — the data written

removeData(path, optQueryParameters)

Delete data at the specified path

  • Parameters:
    • pathstring — - the path where to delete data

    • [optQueryParameters]OptQueryParameters — - a set of query parameters

  • Returns: null

getUrlFromPath(path)

Gets the absolute URL from the specified path

  • Parameters: pathstring — - 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

firebaseapp's People

Contributors

jeanremidelteil avatar romainvialard avatar nicolas-gomez-20 avatar simondebray avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.