8

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?

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
J. Williams
  • 684
  • 1
  • 7
  • 17

2 Answers2

1

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

Abdullah
  • 2,393
  • 1
  • 16
  • 29
0

Had a similar issue,

Someone else created the firebase app for my team, I had owner permissions.

This worked for me, try the command: firebase use --add

Props to Paco Zevallos for a comment that led me to the solution.

I saw this solution at: https://stackoverflow.com/a/45263918/5283424

Check that solution for additional commands and troubleshooting.

Michael Dimmitt
  • 826
  • 10
  • 23