How to implement Firebase AppCheck inside firebase function to read Realtime database?

Viewed 86

In my webapp I make http call to firebase function that reads RealtimeDatabase. Once I enforce AppCheck, this cloud function in unable to access the RealtimeDatabase. Since I use firebase hosting and templating through functions, My static pages with appscript are showing up, But not this http response page.

code in index.js:

const functions = require("firebase-functions");
const admin = require("firebase-admin");
const express = require("express");
const engines = require("consolidate");
require("@firebase/app")
require("@firebase/app-check")

var serviceAccount = require("./firebase-adminsdk-yjm37-b4444555g6.json");
const { request } = require("express");

admin.initializeApp({
    credential: admin.credential.cert(serviceAccount),
    databaseURL: "https://myappname-default-rtdb.asia-southeast1.firebasedatabase.app"
});

admin.appCheck().activate('asdfgRobdfgdrhRXrNHUlBZtz9ctzUMEAVx');

(truncated)

while deploying this function, I get

Error: Error occurred while parsing your function triggers.

TypeError: admin.appCheck(...).activate is not a function

packages listed on the top of the code are updated to the latest version.

(I trying to learn firebase functions and Node.Js through this webapp)

0 Answers
Related