Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

permission error while accessing firestore across project #482

Closed
rmr-code opened this issue Mar 18, 2019 · 4 comments
Closed

permission error while accessing firestore across project #482

rmr-code opened this issue Mar 18, 2019 · 4 comments

Comments

@rmr-code
Copy link

I am in project A and would like to access firestore data in project B.

I have added in Project B IAM, project A's base account (project-a@appspot.gserviceaccount.com) as a service account and assigned it roles of cloud firestore editor.

The rule set for firestore in project B is:

service cloud.firestore {
  match /databases/{database}/documents {
    match /{document=**} {
      allow read, write: if false;
    }
  }
}

In my app, when I try to access project B firestore I receive a permission error. The code is:

let secondaryAppConfig = {
    projectId: project-b,
    databaseURL: let dbURL = 'https://project-b.firebaseio.com';
};
 // create the App
  let secondaryApp = admin.initializeApp(secondaryAppConfig, project-b);
 // get the database object
 secondarydb = admin.firestore(secondaryApp);

However, if I create a private key of the firestore of project B and share it with project A it works. Thus, the following works:

let serviceAccount = require(.. path to key json file ..)
let secondaryAppConfig = {
    credential: admin.credential.cert(serviceAccount),
    databaseURL: let dbURL = 'https://project-b.firebaseio.com';
};

 // create the App
  let secondaryApp = admin.initializeApp(secondaryAppConfig, project-b);
 // get the database object
 secondarydb = admin.firestore(secondaryApp);

What do I need to set in project B to get this working without sharing of the private key? Thanks

@google-oss-bot
Copy link

I found a few problems with this issue:

  • I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.
  • This issue does not seem to follow the issue template. Make sure you provide all the required information.

@hiranya911
Copy link
Contributor

Stackoverflow is the right place to for usage questions such as this. Please follow up at https://stackoverflow.com/questions/55077644/google-function-accessing-firestore-database-of-another-project

@JeongJun-Lee
Copy link

Same here. Is there any solution?

@AshishisLiquid
Copy link

@JeongJun-Lee Maybe this could help you i tried my best to done this. I have done project deployment with single firestore. For Reference My project you can check

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants