firebase-tools icon indicating copy to clipboard operation
firebase-tools copied to clipboard

Firebase login: Unable to authenticate using the provided code

Open zesk6 opened this issue 3 years ago • 16 comments

[REQUIRED] Environment info

firebase-tools: v12.4.8

Windows

firebase login --no-localhost

I am using a proxy (clash for Windows) and cannot log in to Firebase CLI.

The authentication code was supposed to work.

I got an error that says "Unable to authenticate using the provided code. Please try again."

`Firebase optionally collects CLI and Emulator Suite 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 and Emulator Suite usage and error reporting information? Yes i To change your data collection preference at any time, run firebase logout and log in again. [2023-08-16T04:27:46.002Z] >>> [apiv2][query] POST https://auth.firebase.tools/attest [none] [2023-08-16T04:27:46.004Z] >>> [apiv2][body] POST https://auth.firebase.tools/attest {"session_id":"f6b4ff20-dcb1-49a5-b348-fcc806c81c65"}
[2023-08-16T04:27:46.732Z] <<< [apiv2][status] POST https://auth.firebase.tools/attest 200 [2023-08-16T04:27:46.733Z] <<< [apiv2][body] POST https://auth.firebase.tools/attest {"token":"q0VzpDWtS6SX8hO0sZ2ucxMiW1vCl5xKSQdcG9OUXS8"}

To sign in to the Firebase CLI:

  1. Take note of your session ID:

    F6B4F

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

    https://auth.firebase.tools/login?code_challenge=6yNEuyJJwkxXKnWkRv88Xf9iR9e5gthSGg4vLMeZ4gk&session=f6b4ff20-dcb1-49a5-b348-fcc806c81c65&attest=q0VzpDWtS6SX8hO0sZ2ucxMiW1vCl5xKSQdcG9OUXS8

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

? Enter authorization code: 4/0Adeu5BUirvpdmZBEwbsgu5dEl9NM3gcDJRj5uaR4WlJux_Us2ScZCQF2KWdlXczYSNf88Q [2023-08-16T04:28:22.087Z] >>> [apiv2][query] POST https://accounts.google.com/o/oauth2/token [none] [2023-08-16T04:28:22.088Z] >>> [apiv2][body] POST https://accounts.google.com/o/oauth2/token [omitted] [2023-08-16T04:28:32.434Z] *** [apiv2] error from fetch(https://accounts.google.com/o/oauth2/token, {"headers":{},"method":"POST","body":{"_overheadLength":655,"_valueLength":287,"_valuesToMeasure":[],"writable":false,"readable":true,"dataSize":0,"maxDataSize":2097152,"pauseStreams":true,"_released":true,"_streams":[],"_currentStream":null,"_insideLoop":false,"_pendingNext":false,"_boundary":"--------------------------660417251565003746128330","_events":{},"_eventsCount":1}}): FetchError: request to https://accounts.google.com/o/oauth2/token failed, reason: Client network socket disconnected before secure TLS connection was established [2023-08-16T04:28:32.438Z] Token Fetch Error: FirebaseError: Failed to make request to https://accounts.google.com/o/oauth2/token at RetryOperation._fn (C:\Users\xueyi\AppData\Roaming\npm\node_modules\firebase-tools\lib\apiv2.js:239:31) at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

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

zesk6 avatar Aug 16 '23 04:08 zesk6

This issue does not seem to follow the issue template. Make sure you provide all the required information.

google-oss-bot avatar Aug 16 '23 04:08 google-oss-bot

Hi @zesk6, thanks for providing your debug logs. It looks like the request to https://accounts.google.com/o/oauth2/token is not returning a response, and I’m thinking that the proxy you mentioned may be blocking the request . Could you try temporarily disabling the proxy and any VPN you may have, then run firebase login --no-localhost.

Also, are you able to access https://accounts.google.com/o/oauth2/token in the browser, or via curl(curl -I https://accounts.google.com/o/oauth2/token should return a 404 response).

aalej avatar Aug 16 '23 11:08 aalej

I cannot disable my proxy because I am in China. I cannot access any Google services without the proxy.

Also, no 404

zesk6 avatar Aug 19 '23 04:08 zesk6

same question , need hep

lizh2023 avatar Aug 21 '23 07:08 lizh2023

same question , need hep

huangsir0 avatar Sep 27 '23 07:09 huangsir0

same question , need hep

jsnbyxyjsj avatar Sep 29 '23 02:09 jsnbyxyjsj

ame question , need hep

M2dL1fe avatar Nov 23 '23 09:11 M2dL1fe

May I ask if this problem has been solved? I also need help

SPLBJ avatar Nov 27 '23 08:11 SPLBJ

same question

May I ask if this problem has been solved? I also need help

You can try this, it's worked for me. https://github.com/firebase/firebase-tools/issues/1442#issuecomment-1639477997

Sageana avatar Dec 07 '23 02:12 Sageana

Help ...

dwaynefong avatar Apr 18 '24 21:04 dwaynefong

I need help! Nig!!!

Tempalor avatar Apr 29 '24 07:04 Tempalor

Set http_proxy and https_proxy works for me on mac

export http_proxy=http://127.0.0.1:7890
export https_proxy=$http_proxy

and then re-run

firebase  login

ycj3 avatar Jun 28 '24 16:06 ycj3

@CarlsonYuan where did you find the port number 7890?

firstammobile avatar Aug 16 '24 19:08 firstammobile

@CarlsonYuan where did you find the port number 7890?

@firstammobile For me(i'm using ClashX ), it's here:

  1. Open ClashX: Launch the ClashX application on your macOS.
  2. Navigate to the Dashboard: Click on the ClashX icon in your menu bar and select "Dashboard" or "Configs" (depending on the version). This will open a web-based dashboard or a settings window.
  3. Check the Port Configuration: In the dashboard, look for sections like "General" or "Connections." Here, you'll see information about the proxy ports currently being used. Common sections where this information might appear are: HTTP Proxy Port SOCKS5 Proxy Port

ycj3 avatar Aug 19 '24 03:08 ycj3

@CarlsonYuan where did you find the port number 7890? win + R, input resmon to open Resource Monitor, to check your VPN software's PID and seized port. network

set http_proxy=http://127.0.0.1:58309 set https_proxy-http://127.0.0.1:58309 re-run firebase login

works!!!

schunlee avatar Nov 19 '24 09:11 schunlee

🚨 IMPORTANT UPDATE FOR EVERYONE FACING FIREBASE LOGIN ERRORS 🚨

If you are getting any of the following errors while using Firebase CLI, Flutter, Android Studio, PowerShell, or Command Prompt, then this solution may help you:

āŒ Authentication Error: Your credentials are no longer valid. Please run firebase login --reauth

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

āŒ Firebase CLI Login Failed

āŒ Firebase Authentication Error

āŒ Firebase Login Not Working

āŒ Firebase Login Authorization Failed

āŒ Firebase Login Session Expired

āŒ Firebase Login Reauthentication Failed

āŒ Firebase CLI Unable to Authenticate

āŒ Firebase Login Token Expired

āŒ Firebase Login Browser Authentication Failed

I personally faced this problem while configuring Firebase for my Flutter project. I spent a lot of time trying different commands, reinstalling Firebase CLI, and repeating the login process, but the issue continued. After testing multiple solutions, I finally found a working fix.

šŸŽ„ COMPLETE SOLUTION VIDEO:

šŸ‘‰ https://youtu.be/oP3w_OI435s?si=yBOXlHJWGEk4oO2C

Watch the video carefully and follow every step exactly as shown.

This solution may help if you are facing issues while running:

āœ” firebase login

āœ” firebase login --reauth

āœ” firebase login --debug

āœ” firebase logout

āœ” firebase init

āœ” firebase deploy

āœ” firebase projects:list

āœ” flutterfire configure

āœ” npm install -g firebase-tools

Common searches that may bring you here:

firebase login error

firebase authentication error

firebase cli login failed

firebase login unable to authenticate

firebase login credentials are no longer valid

firebase login reauth not working

firebase login authorization code invalid

firebase login browser issue

firebase login powershell error

firebase login windows 11 error

firebase login windows 10 error

firebase login android studio error

firebase login flutter error

firebase deploy authentication failed

firebase init authentication failed

firebase tools login issue

firebase oauth error

firebase cli authentication failed

firebase login code rejected

firebase login token expired

firebase login session invalid

firebase login after entering authorization code error

firebase login command prompt error

firebase login stuck after browser authentication

firebase login not accepting code

firebase cli latest version login issue

firebase login 2026

firebase login fix 2026

firebase authentication solution

firebase login complete fix

āš ļø Before commenting "Not Working", please mention:

1ļøāƒ£ Your Operating System (Windows 10 or Windows 11)

2ļøāƒ£ Firebase CLI Version Run: firebase --version

3ļøāƒ£ Node.js Version Run: node --version

4ļøāƒ£ Exact Error Message

5ļøāƒ£ Screenshot of the Error (if possible)

This helps me understand the issue faster and provide a better solution.

šŸ“§ For additional assistance:

[[email protected]](mailto:[email protected])

I regularly check comments and emails and try to help developers facing Firebase, Flutter, Android Studio, Firebase CLI, Authentication, Deployment, Firestore, Hosting, and FlutterFire configuration issues.

If this solution helped you, please:

šŸ‘ Like the video

šŸ’¬ Comment "Solved"

šŸ“¢ Share it with other Flutter developers

šŸ”” Subscribe for more Firebase and Flutter tutorials

Happy Coding! šŸš€

flutter-for-developers avatar Jun 23 '26 06:06 flutter-for-developers