如何从命令行 (CLI) 更改 Firebase 用户登录身份?
How to change Firebase user login identity from command line (CLI)?
我正在尝试使用 User-Alice.
的登录凭据登录 Firebase
但是当我完成授权程序时,我收到一条消息说我以 User-Bob 身份登录。 This is not mentioned anywhere in the documentation 也没有解释如何更改我登录的用户。
如何将 Firebase 登录用户从 User-Bob 更改为 User-Alice?
谢谢。
通过 CLI 管理多个用户
从 Firebase CLI 版本 9.9.0 开始,您无需重新验证即可管理多个用户。
firebase login:add
firebase login:list
firebase login:use
示例:
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 alice@example.com
将 URL 打印到终端。
firebase login --reauth
在浏览器中使用 link 所需的配置文件。
仍在工作,不太方便的旧答案
处理此问题的最简单方法是注销 User-Alice 和登录的 User-Bob。
firebase logout
firebase login
但是,如果您在浏览器中使用 Google 帐户登录为 User-Alice,则需要先退出。
您必须在(使用)您的主浏览器(比如 Safari)中注销 Google 帐户 。并以正确的用户身份登录到同一浏览器。尝试登录辅助浏览器(例如,Opera 或 Chrome)将无法正常工作。它需要与 Firebase CLI 在点击 firebase login
后自动打开的浏览器相同。次要浏览器将被忽略。
首先,您当前登录的 Google 帐户必须在 默认 浏览器中包含 'User Alice'(userAlice@gmail.com)
。
当你 firebase logout
然后 Firebase 会说
$ firebase logout
Logged out form 'userBob@gmail.com'
firebase login
,Firebase 将打开浏览器并获得确认(允许或拒绝)。当你accept/allow时,你可以在你的终端看到以下内容。
$ 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 'userAlice@gmail.com'
如果您有不同的 google 帐户 - 我建议您在 Google Chrome
中使用不同的浏览器 user profiles
。
在您输入 firebase login
之前,请确保您 激活 相应的浏览器 window 并具有所需的 user profile
。
这样切换账号的时候就不用再输入密码了
使用这个
firebase login --reauth
然后你可以更改帐户
注销和登录命令
firebase logout
firebase login
参考此 link 以获得更多命令
您可以通过此命令获取令牌字符串。
firebase login:ci
然后设置为FIREBASE_TOKEN
环境
您可以保留任意数量的令牌并通过一些实用程序(如 dotenv)自动设置它。
这里有几个解决方案:
firebase logout
firebase login
或者,
firebase login --reauth
2021 年,尝试(在 Windows Powershell 中):
firebase login:ci --interactive
它将生成一个令牌,您将在后续说明中设置该令牌。即要初始化,
firebase init --token "secret-token"
在最近发布的 Firebase CLI (9.9.0) 中,通过新命令支持多个帐户:
- login:use
- login:add
- 登录:列表
参考:https://github.com/firebase/firebase-tools/tree/v9.9.0
所以我用firebase login:add添加了一个新账户然后切换到新添加的账户使用firebase login:use
我正在尝试使用 User-Alice.
的登录凭据登录 Firebase但是当我完成授权程序时,我收到一条消息说我以 User-Bob 身份登录。 This is not mentioned anywhere in the documentation 也没有解释如何更改我登录的用户。
如何将 Firebase 登录用户从 User-Bob 更改为 User-Alice?
谢谢。
通过 CLI 管理多个用户
从 Firebase CLI 版本 9.9.0 开始,您无需重新验证即可管理多个用户。
firebase login:add
firebase login:list
firebase login:use
示例:
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 alice@example.com
将 URL 打印到终端。
firebase login --reauth
在浏览器中使用 link 所需的配置文件。
仍在工作,不太方便的旧答案
处理此问题的最简单方法是注销 User-Alice 和登录的 User-Bob。
firebase logout
firebase login
但是,如果您在浏览器中使用 Google 帐户登录为 User-Alice,则需要先退出。
您必须在(使用)您的主浏览器(比如 Safari)中注销 Google 帐户 。并以正确的用户身份登录到同一浏览器。尝试登录辅助浏览器(例如,Opera 或 Chrome)将无法正常工作。它需要与 Firebase CLI 在点击 firebase login
后自动打开的浏览器相同。次要浏览器将被忽略。
首先,您当前登录的 Google 帐户必须在 默认 浏览器中包含 'User Alice'(userAlice@gmail.com)
。
当你 firebase logout
然后 Firebase 会说
$ firebase logout
Logged out form 'userBob@gmail.com'
firebase login
,Firebase 将打开浏览器并获得确认(允许或拒绝)。当你accept/allow时,你可以在你的终端看到以下内容。
$ 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 'userAlice@gmail.com'
如果您有不同的 google 帐户 - 我建议您在 Google Chrome
中使用不同的浏览器 user profiles
。
在您输入 firebase login
之前,请确保您 激活 相应的浏览器 window 并具有所需的 user profile
。
这样切换账号的时候就不用再输入密码了
使用这个
firebase login --reauth
然后你可以更改帐户
注销和登录命令
firebase logout
firebase login
参考此 link 以获得更多命令
您可以通过此命令获取令牌字符串。
firebase login:ci
然后设置为FIREBASE_TOKEN
环境
您可以保留任意数量的令牌并通过一些实用程序(如 dotenv)自动设置它。
这里有几个解决方案:
firebase logout
firebase login
或者,
firebase login --reauth
2021 年,尝试(在 Windows Powershell 中):
firebase login:ci --interactive
它将生成一个令牌,您将在后续说明中设置该令牌。即要初始化,
firebase init --token "secret-token"
在最近发布的 Firebase CLI (9.9.0) 中,通过新命令支持多个帐户:
- login:use
- login:add
- 登录:列表
参考:https://github.com/firebase/firebase-tools/tree/v9.9.0
所以我用firebase login:add添加了一个新账户然后切换到新添加的账户使用firebase login:use