firebase-tools: Firebase CLI shows projects for wrong, non auth user when I signed out and even when I reinstalled Firebase CLI

[REQUIRED] Environment info

firebase-tools: 8.14.1

Platform: macOS 10.15.7 (19H2)

[REQUIRED] Test case

Firebase console displays project from a non-authenticated user instead of my signed-in user. The behaviour appears to be spontaneous and appears at random. Most of the time Firebase works well, but then without any changes to my environment Firebase starts displaying projects from another user and fails to read .firebaserc correctly. Uninstalling and re-installing the module doesn’t fix the issue.

[REQUIRED] Steps to reproduce

firebase logout
npm uninstall -g firebase-tools
rm /usr/local/bin/firebase

npm i firebase-tools
firebase auth
firebase init
< Configure the new project >
firebase add

This works well. All features work well. However at some point the following two error types begin to appear.

  1. Access errors. Such as: Error: Invalid project selection, please verify project sandbox exists and you have access.
  2. Firebase displays projects from the old user. .firebaserc lists the following projects:
{
  "projects": {
    "default": "apyapp-dev",
    "sandbox": "apyapp-sand",
    "production": "apyapp-production",
    "development": "apyapp-dev"
  },
  "targets": {
    "apyapp-dev": {
      "storage": {
        "main": [
          "apyapp-dev.appspot.com"
        ]
      }
    },
    "apyapp-sand": {
      "storage": {
        "main": [
          "apyapp-sand.appspot.com"
        ]
      }
    },
    "apyapp-production": {
      "storage": {
        "main": [
          "apyapp-production.appspot.com"
        ]
      }
    }
  }
}

However console returns the following:

firebase use           
Active Project: apyapp-dev

Project aliases for /Users/ad/Apps/Cloud-Functions:

  production (apy-app)
  development (apyapp-development)
  sandbox (apyapp-sandbox)

Run firebase use --add to define a new project alias.

[REQUIRED] Expected behavior

firebase use <project_id> to initiate the project_id and not display project from a non-authenticated user.

[REQUIRED] Actual behavior

firebase logout
✔  Logged out from a@apy.app
firebase login --debug
i  Firebase optionally collects CLI usage and error reporting information to help improve our products. Data is collected in accordance with Google's privacy policy (https://policies.google.com/privacy) and is not used to identify you.
 
? Allow Firebase to collect CLI usage and error reporting information? Yes
i  To change your data collection preference at any time, run `firebase logout` and log in again. 

Visit this URL on this device to log in:
https://accounts.google.com/o/oauth2/auth?client_id=563584335869-fgrhgmd47bqnekij5i8b5pr03ho849e6.apps.googleusercontent.com&scope=email%20openid%20https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcloudplatformprojects.readonly%20https%3A%2F%2Fwww.googleapis.com%2Fauth%2Ffirebase%20https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcloud-platform&response_type=code&state=122563152&redirect_uri=http%3A%2F%2Flocalhost%3A9005

Waiting for authentication...
[2020-10-31T16:16:34.513Z] >>> HTTP REQUEST POST https://accounts.google.com/o/oauth2/token  
 {"code":"4/0AfDhmrj0d705mOmIc3Iec3_mDRR9v9SF0Vaudj9I6Lj34BdxlIbhyMorjOfkNedesxja7g","client_id":"563584335869-fgrhgmd47bqnekij5i8b5pr03ho849e6.apps.googleusercontent.com","client_secret":"j9iVZfS8kkCEFUPaAeJV0sAi","redirect_uri":"http://localhost:9005","grant_type":"authorization_code"}
[2020-10-31T16:16:34.954Z] <<< HTTP RESPONSE 200 {"cache-control":"no-cache, no-store, max-age=0, must-revalidate","date":"Sat, 31 Oct 2020 16:16:34 GMT","pragma":"no-cache","expires":"Mon, 01 Jan 1990 00:00:00 GMT","content-type":"application/json; charset=utf-8","vary":"X-Origin, Referer, Origin,Accept-Encoding","server":"scaffolding on HTTPServer2","x-xss-protection":"0","x-frame-options":"SAMEORIGIN","x-content-type-options":"nosniff","alt-svc":"h3-Q050=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000,h3-T051=\":443\"; ma=2592000,h3-T050=\":443\"; ma=2592000,h3-Q046=\":443\"; ma=2592000,h3-Q043=\":443\"; ma=2592000,quic=\":443\"; ma=2592000; v=\"46,43\"","accept-ranges":"none","transfer-encoding":"chunked"}

✔  Success! Logged in as a@apy.app 


firebase use sandbox --debug
[2020-10-31T16:18:19.057Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
[2020-10-31T16:18:19.058Z] > authorizing via signed-in user
[2020-10-31T16:18:19.061Z] > refreshing access token with scopes: ["email","https://www.googleapis.com/auth/cloud-platform","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","openid"]
[2020-10-31T16:18:19.061Z] >>> HTTP REQUEST POST https://www.googleapis.com/oauth2/v3/token  
 <request body omitted>
[2020-10-31T16:18:19.488Z] <<< HTTP RESPONSE 200 {"expires":"Mon, 01 Jan 1990 00:00:00 GMT","cache-control":"no-cache, no-store, max-age=0, must-revalidate","pragma":"no-cache","date":"Sat, 31 Oct 2020 16:18:19 GMT","content-type":"application/json; charset=utf-8","vary":"X-Origin, Referer, Origin,Accept-Encoding","server":"scaffolding on HTTPServer2","x-xss-protection":"0","x-frame-options":"SAMEORIGIN","x-content-type-options":"nosniff","alt-svc":"h3-Q050=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000,h3-T051=\":443\"; ma=2592000,h3-T050=\":443\"; ma=2592000,h3-Q046=\":443\"; ma=2592000,h3-Q043=\":443\"; ma=2592000,quic=\":443\"; ma=2592000; v=\"46,43\"","accept-ranges":"none","transfer-encoding":"chunked"}
[2020-10-31T16:18:19.504Z] >>> HTTP REQUEST GET https://firebase.googleapis.com/v1beta1/projects/apyapp-sandbox  
 
[2020-10-31T16:18:20.163Z] <<< HTTP RESPONSE 403 {"vary":"X-Origin, Referer, Origin,Accept-Encoding","content-type":"application/json; charset=UTF-8","date":"Sat, 31 Oct 2020 16:18:20 GMT","server":"ESF","cache-control":"private","x-xss-protection":"0","x-frame-options":"SAMEORIGIN","x-content-type-options":"nosniff","alt-svc":"h3-Q050=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000,h3-T051=\":443\"; ma=2592000,h3-T050=\":443\"; ma=2592000,h3-Q046=\":443\"; ma=2592000,h3-Q043=\":443\"; ma=2592000,quic=\":443\"; ma=2592000; v=\"46,43\"","accept-ranges":"none","transfer-encoding":"chunked"}
[2020-10-31T16:18:20.163Z] <<< HTTP RESPONSE BODY {"error":{"code":403,"message":"The caller does not have permission","status":"PERMISSION_DENIED"}}
[2020-10-31T16:18:20.165Z] HTTP Error: 403, The caller does not have permission

Error: Invalid project selection, please verify project sandbox exists and you have access.


firebase use production --debug
[2020-10-31T16:19:13.562Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
[2020-10-31T16:19:13.563Z] > authorizing via signed-in user
[2020-10-31T16:19:13.566Z] >>> HTTP REQUEST GET https://firebase.googleapis.com/v1beta1/projects/apy-app  
 
[2020-10-31T16:19:14.521Z] <<< HTTP RESPONSE 403 {"vary":"X-Origin, Referer, Origin,Accept-Encoding","content-type":"application/json; charset=UTF-8","date":"Sat, 31 Oct 2020 16:19:14 GMT","server":"ESF","cache-control":"private","x-xss-protection":"0","x-frame-options":"SAMEORIGIN","x-content-type-options":"nosniff","alt-svc":"h3-Q050=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000,h3-T051=\":443\"; ma=2592000,h3-T050=\":443\"; ma=2592000,h3-Q046=\":443\"; ma=2592000,h3-Q043=\":443\"; ma=2592000,quic=\":443\"; ma=2592000; v=\"46,43\"","accept-ranges":"none","transfer-encoding":"chunked"}
[2020-10-31T16:19:14.521Z] <<< HTTP RESPONSE BODY {"error":{"code":403,"message":"The caller does not have permission","status":"PERMISSION_DENIED"}}
[2020-10-31T16:19:14.523Z] HTTP Error: 403, The caller does not have permission

Error: Invalid project selection, please verify project production exists and you have access.

Having trouble? Try firebase [command] --help


firebase use --debug
[2020-10-31T16:19:43.035Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
[2020-10-31T16:19:43.036Z] > authorizing via signed-in user
Active Project: apyapp-dev

Project aliases for /Users/ad/Apps/Cloud-Functions:

  production (apy-app)
  development (apyapp-development)
  sandbox (apyapp-sandbox)

Run firebase use --add to define a new project alias.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 15 (6 by maintainers)

Most upvoted comments

Nope, still see the wrong projects assigned to me. Even on a brand new system on my new laptop - it’s a config file gone wrong somewhere on Firebase servers. Idk which one though.

On Mon, 22 Nov 2021 at 1:37 am, werder @.***> wrote:

were you able to resolve it? I am facing the same issue. I removed firebase CLI, rebooted, installed it again. Afterwards signed in with my private account but I still see the projects of my work account. Firebase CLI v 9.23.0.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/firebase/firebase-tools/issues/2767#issuecomment-974828751, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAOJXWQDHIMZ2DGLKZ5YZ6TUND73HANCNFSM4TF7GSGQ .

– Kind regards, Artur Daylidonis.

@samtstern just to give you an update. I just cleared all cache, all cookies from all browsers, and removed the firebase-tools.json. After that I restarted my laptop, connected to hotspot, logged in to Firebase, after which I was able to use Firebase CLI and switch projects again. I suppose it’s a workaround but a highly inconvenient one.

@Yorzic I’m a little confused about your issue here but maybe you should look into deleting this file:

~/.config/configstore/firebase-tools.json

That’s where the auth state is stored, it’s possible you have some bad state hanging around there.