I'm creating an electron app as an interface for administrators. Currently using Real-time database and firestore. I'm using the firebase admin sdk with a local .json service account file to connect to the realtime database and perform all un-restricted read/write operations. Everything works as expected. However, when attempting to read/write to the Firestore database, I receive an error:
You need to pass auth instance to use gRPC-fallback client in browser. Use OAuth2Client from google-auth-library.
I did read online that other people had a similar issue and I've tried the following:
- npm rebuild
- install the @grcp/grcp packages
- install the google-auth-library
Unfortunately, I still get the same response. I also get a lot of the following warning messages (each referencing a different js file), not sure if they are related:
DevTools failed to load SourceMap: Could not parse content for file:///Users/anaroca/Desktop/FCF-Admin/node_modules/@google-cloud/firestore/build/src/pool.js.map: Unexpected end of JSON input
This is how I have initiated the admin app:
var admin = require("firebase-admin");
var serviceAccount = require("./secret.json");
app = admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
databaseURL: "https://project-name.firebaseio.com",
projectId: 'project-name'
});
Any help is appreciated.
EDIT: After getting the answer from Dallas, I found this stackoverflow that was a really elegant solution to my problem.