Overview
Client-mode REST API connectors for Firebase: write device state, append events, and query history in the Realtime Database, and upsert, merge, and query Cloud Firestore documents from MQTT. This is one of the templates in the Firebase Realtime Database and Cloud Firestore REST API app (firebase-realtime-database-and-cloud-firestore). Deploy it alongside the other connectors of that app when they depend on each other (for example a token connector plus an API connector). See Firebase Realtime Database and Cloud Firestore for the package overview.
Auth
Bearer {value.json.access_token} on both connectors. RTDB: Google OAuth2 SA token (userinfo.email + firebase.database); alt ?access_token= or Firebase ID token via ?auth=. Firestore: Google OAuth2 SA token (roles/datastore.user) or Firebase ID token (rules apply). Hub secret FIREBASE_ACCESS_TOKEN. Auth headers used by the template:Authorization: Bearer {value.json.access_token}.
Template parameters
BASE_ADDRESS default: https://firestore.googleapis.com.
Events
Deploy
Get the template card (JSON withtemplate and metadata) from the broker, then deploy the connector:
BASE_ADDRESS already filled in:
-addConnector (do not include ADD METADATA).
Usage example
CallUpsertDocument by publishing a JSON payload to its request topic, and read the reply on the response topic:

