I would like a Google Cloud project A (project-a-id) to access the firestore data of another Google Cloud project B (project-b-id). For the same I added project A default service account viz. [email protected]
in the IAM of project B and set the role to Cloud Filestore Editor
.
In the cloud function of project A, I am trying to access both project A's (its own) firestore as well as project B's firestore but it keeps showing project A default database for both Apps. The code is:
var primaryAppConfig = {
databaseURL: 'https://project-a-id.firebaseio.com'
};
var primaryApp = admin.initializeApp(primaryAppConfig, 'primary');
var primarydb = admin.firestore(primaryApp);
var secondaryAppConfig = {
databaseURL: 'https://project-b-id.firebaseio.com'
};
var secondaryApp = admin.initializeApp(secondaryAppConfig, 'secondary');
var secondarydb = admin.firestore(secondaryApp);
I was under the impression if the default service account of project-a is given rights in project-b it should automatically get rights. At least I found it applicable when I am accessing google cloud storage buckets in this manner.
Is something else to be done? Thanks
projectId
option in the app options (especially in thesecondaryAppConfig
). – Tamqrahproject-id
as the same viz. project-a-id – MantoothprojectId:project-b-id
in secondaryAppConfig I get a permission error. I must mention that if I download the private key of the default service account from the project-b settings from firebase console it works by passing it as credentials in secondaryAppConfig. But fail to understand why when I set the project-a default service account in IAM of project-b it does not work. – MantoothError: 7 PERMISSION_DENIED: Missing or insufficient permissions.
– MantoothCloud Firestore Editor
role is insufficient to access the required endpoints. Try giving is a broader set of privileges (I understand it's not a best practice, but at least it will help us understand the problem a little better). I'd say start with theEditor
role on the project. – TamqrahCloud Filestore Editor
is different fromCloud Firestore Editor
. In fact, there is noCloud Firestore Editor
as of now... which makes me wonder if Firestore isn't included in all this. FYI I also triedFirebase Admin
andFirebase Rules Viewer
to no avail. – BridlewiseCloud Datastore
rather thanCloud Firestore
. The permission that was required here isCloud Datastore User
. – Murphree