firebase / firebase-tools

The Firebase Command Line Tools
MIT License
4.01k stars 925 forks source link

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

Closed Aeen07 closed 1 year ago

Aeen07 commented 1 year ago

[REQUIRED] Environment info

firebase-tools: 12.4.0

Platform: Windows

[REQUIRED] Test case

install firebase CLI login to firebase using firebase login run firebase init hosting

[REQUIRED] Steps to reproduce

run firebase init inside a directory when asked Are you ready to proceed? say yes select Hosting: Configure files for Firebase Hosting and (optionally) set up GitHub Action deploys , press spacebar and then enter select use an existing project

[REQUIRED] Expected behavior

lists all projects of firebase to select from

[REQUIRED] Actual behavior

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

firebase-debug.log :

You're about to initialize a Firebase project in this directory:

  D:\host

[warn] !  Unable to fetch the CLI MOTD and remote config. 
[debug] [2023-06-25T05:22:32.724Z] Failed to fetch MOTD FirebaseError: Failed to make request to https://firebase-public.firebaseio.com/cli.json
[info] 
=== Project Setup
[info] 
[info] First, let's associate this project directory with a Firebase project.
[info] You can create multiple project aliases by running firebase use --add, 
[info] but for now we'll just set up a default project.
[info] 
[debug] [2023-06-25T05:24:30.102Z] >>> [apiv2][query] GET https://firebase.googleapis.com/v1beta1/projects pageSize=100
[debug] [2023-06-25T05:24:30.796Z] <<< [apiv2][status] GET https://firebase.googleapis.com/v1beta1/projects 403
[debug] [2023-06-25T05:24:30.796Z] <<< [apiv2][body] GET https://firebase.googleapis.com/v1beta1/projects [omitted]
[debug] [2023-06-25T05:24:30.796Z] Unable to parse JSON: SyntaxError: Unexpected token '<', "<!DOCTYPE "... is not valid JSON
[debug] [2023-06-25T05:24:31.369Z] FirebaseError: Unable to parse JSON: SyntaxError: Unexpected token '<', "<!DOCTYPE "... is not valid JSON
    at RetryOperation._fn (C:\Users\itsae\AppData\Roaming\npm\node_modules\firebase-tools\lib\apiv2.js:260:39)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
[error] 
[error] Error: Failed to list Firebase projects. See firebase-debug.log for more info.
aalej commented 1 year ago

Hi @Aeen07, thanks for reaching out to us. Based on the debug logs you provided, it seems like there is a request that failed due to a permission issue. Could you try running firebase login --reauth to reauthenticate?

Also, could you try connecting to a different network or temporarily turning off any proxy or firewall you may have? This is to discard the possibility that this issue is caused by the network connection.

Lastly, are you able to run firebase projects:list without any issues or does it also result in an error?

Aeen07 commented 1 year ago

thank you for commenting!, I've tried running firebase login --reauth but it didnt work

I cant use firebase without a vpn because of my location (Iran)

I've also tried running firebase projects:list and its giving me the same error

amir-h-e commented 1 year ago

thank you for commenting!, I've tried running firebase login --reauth but it didnt work

I cant use firebase without a vpn because of my location (Iran)

I've also tried running firebase projects:list and its giving me the same error

did you succeed???

lalamoein commented 11 months ago

thank you for commenting!, I've tried running firebase login --reauth but it didnt work

I cant use firebase without a vpn because of my location (Iran)

I've also tried running firebase projects:list and its giving me the same error

daash did you solve the problem ?

Elzazo commented 11 months ago

Hi all, it looks like the transition between your old version of Firebase project and the actual implementation crash on authentication. Or at least that is the problem that the "flutterfire configure" command was issuing when I went reading the log. I had been going to the reauthentication process with the Firebase cli without any success or progress. Unfortunately it looks like the old way, which for me was the use of env variable "FIREBASE_TOKEN" is no longer viable. So this is what I had to do to make things run again: 1) Rename FIREBASE_TOKEN variable to OLD_FIREBASE_TOKEN (just to not lose the content or the reference) 2) Head to https://cloud.google.com/sdk/docs/install download and install gCloud cli (as it was suggested in the logs) 3) Follow the whole installation , checking all the marks at the end, especially "Open gCloud cli" 4) There I went through google authentication (I had to provide the email address) and it loaded all the projects I had on Firebase, I chose to have my main project as the default one (in my case it was marked with "1") 5) Upon the success of the previous step, I found that the cli generated a JSON and that it was under C:\Users\\AppData\Roaming\gcloud\legacy_credentials\\adc.json 6) With this path I created a new env variable named GOOGLE_APPLICATION_CREDENTIALS and value the path in step 5. 7) Reboot the whole system (AndroidStudio was not able to get those env variable changes even when restarted) 8) Launched flutterfire configure from AndroidStudio terminal and it magically created everything. To me it was important that it created the firebase_options.dart file that I had to include in main.dart.

Hope this helped!

jeffala commented 10 months ago

Hi @Aeen07, thanks for reaching out to us. Based on the debug logs you provided, it seems like there is a request that failed due to a permission issue. Could you try running firebase login --reauth to reauthenticate?

Also, could you try connecting to a different network or temporarily turning off any proxy or firewall you may have? This is to discard the possibility that this issue is caused by the network connection.

Lastly, are you able to run firebase projects:list without any issues or does it also result in an error?

I re-authenticated after running: firebase login --reauth and the problem was solved. Thank you @Aeen07

tonymedrano commented 7 months ago

My solution for Angular v17:

npm i @angular/fire (not ng add)

imports:

import { AngularFirestore } from '@angular/fire/compat/firestore';

get AngularFirestore from "compat" folder, after fire

hptigger commented 5 months ago

firebase login --reauth worked for me as well.