Skip to content

Firebase login issue #10681

Closed
Closed

Description

@Purus

[REQUIRED] Environment info
Firebase CLI Version: 15.21.0
Node.js Version: v24.17.0
Windows 11 x64

[REQUIRED] Test case
Download firebase-tools and authenticate from the terminal

[REQUIRED] Steps to reproduce
Execute firebase login, firebase login --reauth, firebase login --no-localhost and basically all versions of authentication available. Including ones with login:ci

[REQUIRED] Expected behavior
The authentication should complete successfully within the terminal

[REQUIRED] Actual behavior
The CLI opens a browser window for authentication.
The browser displays the following error message:
Oops!
Firebase CLI Login Failed
The Firebase CLI login request was rejected or an error occurred. Please run firebase login again or contact support if you continue to have difficulty logging in.
Meanwhile, the terminal outputs the following logs:

C:\Users\purus>firebase login --no-localhost --reauth --debug
[2026-06-18T11:51:31.707Z] >>> [apiv2][query] POST https://auth.firebase.tools/attest [none]
[2026-06-18T11:51:31.708Z] >>> [apiv2][body] POST https://auth.firebase.tools/attest {"session_id":"7966cbb3-142a-46b4-b571-e92f722dcd9c"}
[2026-06-18T11:51:32.374Z] <<< [apiv2][status] POST https://auth.firebase.tools/attest 200
[2026-06-18T11:51:32.374Z] <<< [apiv2][body] POST https://auth.firebase.tools/attest {"token":"yJah2vT3KoOXOwvO7LZda_h8aE0tl5KTwiG68UK3CZQ"}

To sign in to the Firebase CLI:

1. Take note of your session ID:

   7966C

2. Visit the URL below on any device and follow the instructions to get your code:

   https://auth.firebase.tools/login?code_challenge=AeIjhcJ5ZQk9VfnNwNbDRz1Qnjj4qZt69Hb7Ek9oRvM&session=7966cbb3-142a-46b4-b571-e92f722dcd9c&attest=yJah2vT3KoOXOwvO7LZda_h8aE0tl5KTwiG68UK3CZQ

3. Paste or enter the authorization code below once you have it:

√ Enter authorization code: 4/0AdkVLPx31jGpY5NaS430JKunW2-w9iGknbn-O3Vpn6QYsWG-aJHqiUGX7w3b5VAzNMaNlA
[2026-06-18T11:51:57.133Z] >>> [apiv2][query] POST https://accounts.google.com/o/oauth2/token [none]
[2026-06-18T11:51:57.134Z] >>> [apiv2][body] POST https://accounts.google.com/o/oauth2/token [omitted]
[2026-06-18T11:51:57.312Z] Token Fetch Error: FirebaseError: FetchError: Invalid response body while trying to fetch https://accounts.google.com/o/oauth2/token: Premature close
    at RetryOperation._fn (F:\node-v24.17.0-win-x64\node_modules\firebase-tools\lib\apiv2.js:317:88)
    at process.processTicksAndRejections (node:internal/process/task_queues:104:5)
Authentication Error: Your credentials are no longer valid. Please run firebase login --reauth

For CI servers and headless environments, generate a new token with firebase login:ci

Error: Unable to authenticate using the provided code. Please try again.

I tried to do a curl to the auth url as below.

C:\Users\purus>curl -X POST -I https://accounts.google.com/o/oauth2/token
HTTP/1.0 411 Length Required
Content-Type: text/html; charset=UTF-8
Referrer-Policy: no-referrer
Content-Length: 1564
Date: Thu, 18 Jun 2026 11:53:09 GMT

I have treid to change different wifi band, mobile data using hotspot too.. still the same issue.

Activity

  1. tobiaschristensen commented on Jun 18, 2026

    @tobiaschristensen

    Same issue on MacOS with Firebase CLI 15.20.0. Works with Node 24.16.0.

    Investigation by Claude:

    Bisects to Node 24.17.0 (24.16.0 works); independent of firebase-tools version.

    firebase login / --reauth fail on the token exchange — POST /o/oauth2/token in getTokensFromAuthorizationCode, via the apiv2 node-fetch client:

    FetchError: Invalid response body while trying to fetch https://accounts.google.com/o/oauth2/token: Premature close
    

    --no-localhost fails the same way (same getTokensFromAuthorizationCode path), and the same call is used for token refresh in hosting:channel:deploy — there it surfaces as "credentials no longer valid" (it failed on Node 24.x but completed on 22.14 with unchanged credentials).

    Node bisection (6/6 runs each, macOS arm64; the linked report is Windows 11, so cross-platform):

    • 24.17.0 — Premature close
    • 24.16.0 — ok
    • 22.14.0 — ok

    Not a CLI-version issue: reproduced on firebase-tools 14.27 and 15.20.0 (this report is on 15.21.0) — all still use node-fetch v2 for this call, so upgrading the CLI doesn't help.

    node-fetch-specific. Same endpoint, Node 24.17.0: curl completes (400/411) and Node's built-in fetch/undici returns 400 (6/6); only node-fetch v2 throws Premature close (6/6):

    const fetch = require('node-fetch')
    const FormData = require('form-data')
    const f = new FormData(); f.append('grant_type', 'authorization_code'); f.append('code', 'x')
    const r = await fetch('https://accounts.google.com/o/oauth2/token', { method: 'POST', body: f, headers: f.getHeaders() })
    await r.text() // Premature close on 24.17.0, fine on 24.16.0

    24.17.0 is a security release (11 CVEs); I haven't bisected the exact commit, but the likeliest candidate is CVE-2026-48931 ("fix response queue poisoning in http.Agent"), given node-fetch's known http.Agent Premature-close behavior — the TLS fixes look less relevant. Since undici works on 24.17, moving apiv2 off node-fetch to the built-in fetch should resolve it. Workaround meanwhile: Node 24.16 (predates this security release).

  2. Purus commented on Jun 18, 2026

    @Purus
    Author

    Wow.. you saved me from lot of frustration.

    It worked with 24.16.0. thanks a lot.

  3. SveBo commented on Jun 18, 2026

    @SveBo

    Node 22.23 also breaks firebase login, node 22.22 works!

  4. joehan commented on Jun 18, 2026

    @joehan
    Member

    Reproduced this issue too - unfortunately, I don't believe that there is any action that can be taken in this repo to fix the issue. Root cause here is to be nodejs/node#63989, which is breaking google-auth-library. Fortunately, the Node maintainers seem to be actively responding.

    As others have mentioned - if you are experiencing this issue, please downgrade to Node 22.22.x or Node 24.16.x and bump nodejs/node#63989

  5. pearigee commented on Jun 18, 2026

    @pearigee

    This may not impact newer versions of google-auth-library (which are using a newer version of gaxios->node-fetch).

    I see this repo is using "google-auth-library": "^9.11.0",. Upgrading to the current version 10.7.0 may resolve this issue.

  6. filoscoder commented on Jun 19, 2026

    @filoscoder

    Confirmed Node 24.16 is working.

  7. Ziad-Mahmoud commented on Jun 20, 2026

    @Ziad-Mahmoud

    It Works by downgrade from 17 to 16
    nvm install 24.16.0
    nvm use 24.16.0
    Thanks a lot both to make an issue Purus and to fix it tobiaschristensen

  8. basitkhan32 commented on Jun 21, 2026

    @basitkhan32

    Worked with:

    • Node v24.16.0
    • npm 11.16.0
    • firebase-tools 15.22.0
    • nvm 0.40.3
    • macOS
  9. cjsewell commented on Jun 22, 2026

    @cjsewell
    Contributor

    I (well claude really) work around this with

    no-keepalive.cjs:

    const http = require("http");
    const https = require("https");
    
    http.globalAgent = new http.Agent({ keepAlive: false });
    https.globalAgent = new https.Agent({ keepAlive: false });
    
    NODE_OPTIONS="--require ${ROOT_DIR}/scripts/no-keepalive.cjs ${NODE_OPTIONS:-}" \
      npx -y firebase-tools@15.6.0 deploy ....
    
  10. danigc commented on Jun 23, 2026

    @danigc

    Thanks a lot. As commented before by @SveBo 22.23 released five days ago also breaks login

  11. JamesJoyceGit commented on Jun 28, 2026

    @JamesJoyceGit

    In case someone else has this happen unexpectedly - I added caching to by git actions - and somehow it decided to use v24.17! And failed on google auth login...

    So - I fixed it to v24.18.0 - and this solved the issue
    - name: Setup node uses: actions/setup-node@v6 with: node-version: 24.18.0 cache: "npm"

  12. greg-md commented on Jul 3, 2026

    @greg-md

    I am having the same issue, but it does open the browser and on login it breaks with 400 error on https://accounts.google.pt/accounts/SetSID

    Any ideas? Switching to v24.16.0 did not help.

  13. mdulc928 commented on Jul 13, 2026

    @mdulc928

    Downgrading to 22.22 worked. Thanks for all the suggestions, guys!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions