How do I solve: Error: Failed to list Firebase projects. See firebase-debug.log for more info

How do I solve: Error: Failed to list Firebase projects. See firebase-debug.log for more info

所以我正在考虑自己的事情,试图在我的 Angular 应用程序中初始化一个 Firebase 项目,突然我遇到了这个错误:

Error: Failed to list Firebase projects. See firebase-debug.log for more info.

为了达到这一点,我遵循了文档 here 中的说明,这些说明基本上是 运行:

$ npm install -g firebase-tools

$ firebase login // Turns out I was already logged in

$ firebase projects:list // Make sure you can access your account.

不管怎样,回到错误。 “好吧,”我想。 “我会检查它指向我的日志。”我打开日志看到:

HTTP Error: 401, Request had invalid authentication credentials. 
Expected OAuth 2 access token, login cookie or other valid authentication credential.
See https://developers.google.com/identity/sign-in/web/devconsole-project.`
`FirebaseError: HTTP Error: 401, Request had invalid authentication credentials.
Expected OAuth 2 access token, login cookie or other valid authentication credential.
See https://developers.google.com/identity/sign-in/web/devconsole-project.`

关于“无效的身份验证凭据”的部分让我认为这与我没有登录 firebase 有关,但 firebase login 显示我已登录。

日志中的 URL 只是将我带到了在我的应用程序中使用 firebase 身份验证的文档。好吧,我很乐意。但首先我需要这个命令才能工作,Firebase。

有人 运行 this/have 有解决方案吗?

更新

修复方法是:

$ firebase login --reauth

感谢@kynan 在评论中将原来的两行简化为一行。

如果还是不行,您也可以像原来的回答一样,尝试注销再重新登录。


原答案

修复方法是:

$ firebase logout

$ firebase login

看起来当您升级 firebase-tools 时,可能会使您的授权令牌失效。您只需注销并重新登录。

这是您注销时的消息:

$ firebase logout
!  Invalid refresh token, did not need to deauthorize
+  Logged out from <email>

使用firebase logout注销 然后使用 firebase login 在 CLI

中重新登录 firebase

使用 npm install -g firebase-tools

更新 Firebase 工具后执行此操作

登录成功后,使用firebase use --add列出您拥有的所有项目

对于不想退出的人,下面的命令也可以。

firebase login --reauth

在我无法列出我的 firebase 项目的情况下,我尝试通过安装在我的系统(而不是我的浏览器)上的 vpn 访问 firebase,并且它有效。然后我可以在我的项目中初始化 firebase 作为托管和部署它。

对于不想注销的用户,以下命令也有效

firebase login --reauth

首先转到命令提示符和 运行 下面的代码,然后执行上面的代码。 在命令提示符中:

运行 : powershell Set-ExecutionPolicy RemoteSigned -Scope CurrentUser