How to change Firebase user login identity from command line (CLI)?

Command LineFirebaseCommand Line-Interface

Command Line Problem Overview


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.

Command Line Solutions


Solution 1 - Command Line

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 david@example.com
firebase login:add alice@example.com
firebase login:add bob@example.com
firebase login:use alice@example.com
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 - Command Line

use this

firebase login --reauth

then you can change account

Solution 3 - Command Line

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 Line

Command for logout and login

firebase logout
firebase login

refer this link for more commands

https://www.npmjs.com/package/firebase-tools

Solution 5 - Command Line

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.

Solution 6 - Command Line

Here are a few solutions:

firebase logout
firebase login

Or,

firebase login --reauth

Solution 7 - Command Line

First, your currently log in Google account must include 'User Alice'([email protected]) in your default browser. When you firebase logout and then Firebase will say

$ firebase logout
Logged out form '[email protected]'

firebase login, Firebase will open a browser and get the comfirmation (allow or deny). When you accept/allow, you can see the following in your terminal.

$ firebase login
Allow Firebase to collect anonymous CLI usage information? Yes

Visit this URL on any device to log in:
https://accounts.google.com/o/oauth2/auth?client_id=....

Waiting for authentication...

Success! Logged in as '[email protected]'

Solution 8 - Command Line

You have to log out of Google Accounts in (using) your primary browser (say, Safari). And log in to that same browser as the correct user. Trying to login to secondary browsers (say, Opera or Chrome) won't work. It needs to be the same browser that Firebase CLI opens automatically after hitting firebase login. Secondary browsers will be ignored.

Solution 9 - Command Line

If you have different google accounts - I recommend you have different browser user profiles for it in Google Chrome.

Before you enter firebase login, make sure you activate the respective browser window with the desired user profile.

This way you will not have to enter passwords again when switching accounts.

Solution 10 - Command Line

In 2021, Try (In Windows Powershell):

firebase login:ci --interactive

It will generate a token that you will set in your subsequent instructions. i.e. To init,

firebase init --token "secret-token"

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionLet Me Tink About ItView Question on Stackoverflow
Solution 1 - Command LineDavid EastView Answer on Stackoverflow
Solution 2 - Command Linejohn leeView Answer on Stackoverflow
Solution 3 - Command LineBrahmdevView Answer on Stackoverflow
Solution 4 - Command Linesaigopi.meView Answer on Stackoverflow
Solution 5 - Command LinekuboonView Answer on Stackoverflow
Solution 6 - Command LineA v o c a d oView Answer on Stackoverflow
Solution 7 - Command LineNyeinView Answer on Stackoverflow
Solution 8 - Command LineLet Me Tink About ItView Answer on Stackoverflow
Solution 9 - Command LineUjjwal SinghView Answer on Stackoverflow
Solution 10 - Command Linetunde ODUGUWA IIIView Answer on Stackoverflow