I am developing a web application. I deployed my website to one project and want to get firestore data from another project. So I added two projects configurations in html file. To call the data from second firebase project I declared a variable like below.
var config = {
apiKey: "<API_KEY>",
authDomain: "<PROJECT_ID>.firebaseapp.com",
databaseURL: "https://<DATABASE_NAME>.firebaseio.com",
storageBucket: "<BUCKET>.appspot.com",
};
var secondaryAppConfig = {
apiKey: "<API_KEY>",
authDomain: "<PROJECT_ID>.firebaseapp.com",
databaseURL: "https://<DATABASE_NAME>.firebaseio.com",
storageBucket: "<BUCKET>.appspot.com",
};
var secondary = firebase.initializeApp(secondaryAppConfig, "secondary");
var secondaryFirestore = secondary.database();
secondaryFirestore.collection('sample').get().then(snap => {
var size = snap.size;
console.log("TotalSample",size);
// will return the collection size
document.getElementById('totalStores').textContent = size;
});
When I wrote a query to get data from secondaryFirestore like above I am getting the error like
error.js:149 Uncaught (in promise) Error: Missing or insufficient permissions.
at new e (error.js:149)
at t.fromRpcStatus (serializer.js:93)
at t.fromWatchChange (serializer.js:573)
at e.onMessage (persistent_stream.js:391)
at persistent_stream.js:333
at persistent_stream.js:308
at async_queue.js:83
Project-A database rules are like only authenticated people can access the data. I can't change that rules because it is confidential. Actually in both database projects I am signing with same email id. I struct at this point. I tried a lot can't get any idea. Please let me know any idea about how to access the data from secondaryFirestore database.
Thanks in advance.
Aucun commentaire:
Enregistrer un commentaire