FlutterFire cli - how to switch between separate firebase consoles

Viewed 909

I have two separate firebase consoles accessed from two separate google accounts.

  • Firebase console "A" has three projects. Google account a@gmail.com
  • Firebase console "B" has one project. Google account b@gmail.com

Originally, I set up the Firebase "A" console using flutterfire cli flutterfire configure and it worked just fine, but setting up "B", it seems like there is some kind of caching for "A" issue.

In my completely separate google account for firebase console "B" I have created a project that I now need to run flutterfire configure for in the separate directory for project "B".

Using firebase login:add a@gmail.com and firebase login:add b@gmail.com. Both accounts have been authed, no problem. So I should be able to use firebase login:use to switch between the two, however flutterfire configure and firebase projects:list do not seem to respect which firebase account I'm signed into. They only show the projects for "A", never "B".

For example, switching to the directory for firebase project "B", I run firebase login:use b@gmail.com and then flutterfire configure --account=b@gmail.com. flutterfire configure, incorrectly, the 3 projects from "A". Running firebase projects:list in directory "B" after running firebase login:use b@gmail.com, only shows the projects from "A", not the 1 project I'm expecting to see from project "B".

In the directory for project "B", I tried running firebase init and it correctly listed my 1 project for "B" and I was able to init. But immediately after the init, running flutterfire configure or flutterfire configure --account=b@gmail.com, in the directory for "B", the following exception is returned, stating it can't find project "B" in the firebase account for "A". Notice that it states it "Found 3 Firebase projects", but project "B" only has 1 project, "A" has 3 projects.

i Found 3 Firebase projects. Selecting project B.
FirebaseProjectNotFoundException: Firebase project id "B" could not be found on this Firebase account.

And I am signed into to "B", not "A". Some kind of cache issue? How do I break the cache?

I have completely removed npm -g firebase-tools and flutterfire from dart global. I've deleted all .firebaserc and firebase.json files I could find. None of it worked.

ANSWER (for my use case):

If you're having issues switching accounts firebase projects:list --debug may very well give you the insight for more difficult issues like mine here.

Using firebase projects:list --debug I saw that the authorization was using an ENV FIREBASE_TOKEN, which at some point I must have put into my ~/.bashrc. This token was for project "A". I removed the ENV token and now everything is working as expected.

2 Answers

I had the same scenario. What worked for me was the following:

Add the A account in the possible accounts to use.

firebase login:add a@gmail.com

Configure project selection with correct account.

flutterfire configure --account a@gmail.com

Step 1: See all available accounts

 firebase login:list  

Step 2: Add more accounts:

firebase login:add email@email.com

Step 3: Switch to another email

firebase login:list  (to see if email was successfully added)
firebase login:use whateverEmail@email.com (to switch email)

Step 4 :

flutterfire configure --account whateverEmail@email.com
Related