How to change Firebase user login identity from command line (CLI)?
I'm trying to login to Firebase using login credentials of, let's say, User-Alice.
But when I go through the authorization procedure I get a message saying I'm logged in as User-Bob. This is not mentioned anywhere in the documentation nor does it explain how to change the user I'm logged in as.
How can I change the Firebase logged in user from User-Bob to User-Alice?
Thank you.
Solution 1:
Manage multiple users via the CLI
You can manage multiple users without re-authenticating, as of version 9.9.0 of the Firebase CLI.
firebase login:add
firebase login:list
firebase login:use
Example:
firebase login:add [email protected]
firebase login:add [email protected]
firebase login:add [email protected]
firebase login:use [email protected]
firebase login:list
firebase deploy --only hosting # deploy as [email protected]
Get a URL printed to the terminal.
firebase login --reauth
Use that link in the browser with the needed profile.
Still working, less convenient older answer
The easiest way to handle this is to logout User-Alice and the login User-Bob.
firebase logout
firebase login
But, if you're logged as User-Alice with a Google account in the browser you'll need to sign out there first.
Solution 2:
use this
firebase login --reauth
then you can change account
Solution 3:
In the recent release of Firebase CLI (9.9.0) there was support for multiple accounts via new commands:
- login:use
- login:add
- login:list
Reference: https://github.com/firebase/firebase-tools/tree/v9.9.0
So I used firebase login:add to add a new account and then switched to newly added account use firebase login:use
Solution 4:
Command for logout and login
firebase logout
firebase login
refer this link for more commands
https://www.npmjs.com/package/firebase-tools
Solution 5:
You can get token string by this command.
firebase login:ci
Then set it to FIREBASE_TOKEN
env.
You can keep any number of tokens and set it automatically by some utils like dotenv.