Firebase login: Unable to authenticate using the provided code
[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:
-
Take note of your session ID:
F6B4F
-
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
-
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.`
This issue does not seem to follow the issue template. Make sure you provide all the required information.
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).
I cannot disable my proxy because I am in China. I cannot access any Google services without the proxy.
Also, no
same question , need hep
same question , need hep
same question , need hep
ame question , need hep
May I ask if this problem has been solved? I also need help
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
Help ...
I need help! Nig!!!
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
@CarlsonYuan where did you find the port number 7890?
@CarlsonYuan where did you find the port number
7890?
@firstammobile For me(i'm using ClashX ), it's here:
- Open ClashX: Launch the ClashX application on your macOS.
- 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.
- 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 PortSOCKS5 Proxy Port
@CarlsonYuan where did you find the port number
7890? win + R, inputresmonto open Resource Monitor, to check your VPN software's PID and seized port.
set http_proxy=http://127.0.0.1:58309 set https_proxy-http://127.0.0.1:58309 re-run firebase login
works!!!
šØ 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! š