Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cross-project access to Firebase Database from a service account

I have a Firebase project that does not have billing enabled. I want to create database backups using a VM that belongs to another, billing-enabled project. The backup script is as simple as:

.npm/bin/firebase --project $PROJECT_ID database:get /

A freshly created Service Account is assigned to the VM running this script (through GCE). If this account doesn't have access to project $PROJECT_ID, then obviously this fails:

Error: Authorization failed. This account is missing the following required permissions on project $PROJECT_ID:

firebase.projects.get
firebasedatabase.instances.get

But giving these specific permissions to the service account, or even assigning "Owner" role to that project doesn't make it much better. Instead:

Error: HTTP Error: 404, The specified project was not found.

Running with --debug shows that specifically GET https://admin.firebase.com/v1/projects/$PROJECT_ID returns 404.

The project exists, which I verify by running the exact same command with my own (non-service) account on my workstation. I have also verified that the account is the correct one by running gcloud auth list on the VM. The project also shows up in the gcloud projects list output on the same VM.

Is there a way to make the service account work cross-project and access Firebase Database?

like image 297
J. Williams Avatar asked Oct 14 '18 08:10

J. Williams


People also ask

Can two apps use the same Firebase database?

Yes, You can use the same firebase database in more than one android application as below: In the Project Overview section of Firebase Console add an android application. For adding this application first you need to give that package name.


1 Answers

enter image description here

Run Below Command in your cli: firebase use --add

I saw this solution at : https://firebase.google.com/docs/hosting/?authuser=0

like image 153
Abdullah Avatar answered Oct 11 '22 00:10

Abdullah