firebase-tools: firebase login: Token Fetch Error

Hi,

I’m having some trouble to login.

Version info

3.13.0

Steps to reproduce

$ firebase login --no-localhost --debug

Expected behavior

A sucessful login

Actual behavior

$ firebase login --no-localhost --debug
[2017-10-03T18:14:05.541Z] ----------------------------------------------------------------------
[2017-10-03T18:14:05.546Z] Command:       /usr/local/bin/node /usr/local/bin/firebase login --no-localhost --debug
[2017-10-03T18:14:05.546Z] CLI Version:   3.13.0
[2017-10-03T18:14:05.546Z] Platform:      linux
[2017-10-03T18:14:05.546Z] Node Version:  v8.6.0
[2017-10-03T18:14:05.547Z] Time:          Tue Oct 03 2017 15:14:05 GMT-0300 (BRT)
[2017-10-03T18:14:05.547Z] ----------------------------------------------------------------------

? Allow Firebase to collect anonymous CLI usage and error reporting information? No

Visit this URL on any 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=866083077&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob

? Paste authorization code here: 4/9FxonAqbx4paDM4BWzPaSLFuLbAUaTB8bS65YK5R_vc
[2017-10-03T18:14:20.567Z] >>> HTTP REQUEST POST https://accounts.google.com/o/oauth2/token { code: '4/9FxonAqbx4paDM4BWzPaSLFuLbAUaTB8bS65YK5R_vc',
  client_id: '563584335869-fgrhgmd47bqnekij5i8b5pr03ho849e6.apps.googleusercontent.com',
  client_secret: 'j9iVZfS8kkCEFUPaAeJV0sAi',
  redirect_uri: 'urn:ietf:wg:oauth:2.0:oob',
  grant_type: 'authorization_code' } 
 Tue Oct 03 2017 15:14:20 GMT-0300 (BRT)
[2017-10-03T18:14:20.582Z] Token Fetch Error: Error
    at FirebaseError (/usr/local/lib/node_modules/firebase-tools/lib/error.js:11:17)
    at Request._callback (/usr/local/lib/node_modules/firebase-tools/lib/api.js:32:23)
    at self.callback (/usr/local/lib/node_modules/firebase-tools/node_modules/request/request.js:186:22)
    at emitOne (events.js:115:13)
    at Request.emit (events.js:210:7)
    at Request.onRequestError (/usr/local/lib/node_modules/firebase-tools/node_modules/request/request.js:878:8)
    at emitOne (events.js:115:13)
    at ClientRequest.emit (events.js:210:7)
    at ClientRequest.onError (/usr/local/lib/node_modules/firebase-tools/node_modules/tunnel-agent/index.js:179:21)
    at Object.onceWrapper (events.js:316:30)

Error: 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

Someone knows what’s going on?

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 13
  • Comments: 48 (2 by maintainers)

Commits related to this issue

Most upvoted comments

I had the same issue and occasionally this helped me: set "NODE_TLS_REJECT_UNAUTHORIZED=0" and then re-run firebase login

A way to solve it is to just do:

firebase logout which will log you out and log in again with firebase login

If you’re in China, set a proxy like shadowsocks in your console. ~/.zshrc

function proxy() {
	export http_proxy="http://192.168.1.100:1087"
	export https_proxy="http://192.168.1.100:1087"
	export all_proxy="http://192.168.1.100:1087"
}

function unproxy() {
	unset http_proxy https_proxy all_proxy
}

I was running into this exact same issue. I restarted my machine–restarting Docker was probably enough, but hey!–and ran docker system prune.

Once Docker was completely fresh, I ran my build again and it worked just fine.

I also added set "NODE_TLS_REJECT_UNAUTHORIZED=0" to my build script… so that could have helped too?

I am getting the same issue. I tried the same thing yesterday it was working perfectly fine. but now i am getting an authorization error. I have also attached the snapshot.

image

exec the command export https_proxy=http://127.0.0.1:7890 http_proxy=http://127.0.0.1:7890 all_proxy=socks5://127.0.0.1:7890 in bash, it works for me

i use clashX for mac, because china can’t use google service.

In bash:

export NODE_TLS_REJECT_UNAUTHORIZED=0

@daryoooooo just do it in bash

In case if someone uses firebase-cli behind corporate proxy with self-signed certificate:

  1. set proxy settings as env variables.
  2. set env variable NODE_EXTRA_CA_CERTS to the path of the self-signed certificate.

I was able to solve the issue on my side; this was in fact linked to that problem: https://github.com/firebase/firebase-admin-node/issues/115

Fixed it adding ugly code process.env[“NODE_TLS_REJECT_UNAUTHORIZED”] = 0; in api.js before the request call

no @laurenzlong, even this didn’t work

To follow up, in trying to reinstall the NPM package for Firebase Tools to see if that might make a difference NPM failed in a way that smelled like a DNS issue. I restarted the computer (macOS 10.12.6 Sierra) and then both the NPM install and the reauth of Firebase Tools went through.

As such I can’t tell with certainty that the two issues were related. However, a reboot of your computer might just be a thing to try if you’re experiencing this issue.