Firebase-admin-node: Firebase fails to fetch a valid Google OAuth2 access token on Windows

Created on 8 Jan 2019  路  14Comments  路  Source: firebase/firebase-admin-node

  • Operating System version: Windows 10
  • Firebase SDK version: no SDK used
  • Library version: [email protected]
  • Firebase Product: Realtime database

[REQUIRED] Step 3: Describe the problem

I built a script to download data from the Realtime database, on Mac. Here things work fine. But when tested the script on Windows I get the following error:

@firebase/database: FIREBASE WARNING: {"code":"app/invalid-credential","message":"Credential implementation provided to initializeApp() via the \"credential\" property failed to fetch a valid Google OAuth2 access token with the following error: \"Failed to parse access token response: Error: Server responded with status 400.\"."}

Steps to reproduce:

Build a script that access data from Realtime database, using firebase-admin. Run it on Windows.

Relevant Code:

var admin = require("firebase-admin");
var serviceAccount = require("./adminsdk.json");
admin.initializeApp({
  credential: admin.credential.cert(serviceAccount),
  databaseURL: "https://<project-id>.firebaseio.com"
});
var db = admin.database();
var dataRef = db.ref("ref");

Most helpful comment

i am experiencing the same issue but when i am running my Nodejs application in a docker container.

@firebase/database: FIREBASE WARNING: {"code":"app/invalid-credential","message":"Credential implementation provided to initializeApp() via the \"credential\" property failed to fetch a valid Google OAuth2 access token with the following error: \"Error fetching access token: Error while making request: getaddrinfo EAI_AGAIN accounts.google.com:443. Error code: EAI_AGAIN\"."}

clocks is synced, is there anyone with the same issue as me ?

All 14 comments

I found a few problems with this issue:

  • I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.
  • This issue does not seem to follow the issue template. Make sure you provide all the required information.

Possible causes include:

  1. Clock out of sync (most likely, since you're only seeing this on one environment)
  2. Service account and the database URL are for 2 different projects

Please use Stackoverflow if you wish to follow up with further questions.

@hiranya911 it worked. Thank you!

@hiranya911 How did you fix the clock sync error?

@hiranya911 How did you solve clock sync error?

Can u provide solution for me

Thanks

Not sure how to fix it for Windows. On Linux you would usually use a service like ntp.

@Andrewvanbeek @meet02 on Windows you just update the OS clock. Something like update current time. I am using dual boot, and every time I log in my Linux distro the windows clock gets desyncronised

On windows, I was able to fix the issue by navigating to change date and time settings > Internet time > change settings > Update now * with the *synchronize with the internet server checkbox checked.

i am experiencing the same issue but when i am running my Nodejs application in a docker container.

@firebase/database: FIREBASE WARNING: {"code":"app/invalid-credential","message":"Credential implementation provided to initializeApp() via the \"credential\" property failed to fetch a valid Google OAuth2 access token with the following error: \"Error fetching access token: Error while making request: getaddrinfo EAI_AGAIN accounts.google.com:443. Error code: EAI_AGAIN\"."}

clocks is synced, is there anyone with the same issue as me ?

Still facing this issue... wish you guys had some guidance because I've already spent a few hours on this :/

I am having this issue too and im not having a clue of where to start to solve it.

For those who are facing this issue, I actually found out that this lib is just for node environments, that is, if you have an frontend app (like my case, a reactjs web app) it won't work. I figured I will probably have to use firebase functions get what I want done (which is deleting a user from firebase auth by UID).

If anyone has anything to add or confirm my thoughts I would really appreciate as well...

My problem was solved sending the data as a miltipart form instead of a json. Forcing us to not use json in node... Wtf.

My problem was solved sending the data as a miltipart form instead of a json. Forcing us to not use json in node... Wtf.

@DiegoMGar Can you elaborate on what you changed to a multipart form? This issue just crept up and I wasn't having problems in the past. Any data you can provide will be extremely helpful!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jamescrowley picture jamescrowley  路  3Comments

cmdhema picture cmdhema  路  3Comments

hiranya911 picture hiranya911  路  5Comments

peterwiebe picture peterwiebe  路  3Comments

cbrwizard picture cbrwizard  路  5Comments