Skip to content

Firebase fails to fetch a valid Google OAuth2 access token on Windows #436

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
gabimoncha opened this issue Jan 8, 2019 · 15 comments
Closed

Comments

@gabimoncha
Copy link

gabimoncha commented Jan 8, 2019

  • 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");
@google-oss-bot
Copy link

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.

@hiranya911
Copy link
Contributor

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.

@gabimoncha
Copy link
Author

gabimoncha commented Jan 9, 2019

@hiranya911 it worked. Thank you!

@Andrewvanbeek
Copy link

@hiranya911 How did you fix the clock sync error?

@meet02
Copy link

meet02 commented Feb 25, 2019

@hiranya911 How did you solve clock sync error?

Can u provide solution for me

Thanks

@hiranya911
Copy link
Contributor

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

@gabimoncha
Copy link
Author

@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

@Wokoro
Copy link

Wokoro commented Oct 15, 2019

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.

@EitanK96
Copy link

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 ?

@GustavoHGS
Copy link

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

@diekotto
Copy link

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

@GustavoHGS
Copy link

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...

@diekotto
Copy link

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

@kennydifiore
Copy link

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!

@arol
Copy link

arol commented Dec 6, 2023

Just for reference in case someone is looking for a solution:

One of my students was having this issue with Windows (WSL).
Indeed the error was a clock out of sync, but Windows clock was ok.
The problem was that the Linux clock (WSL) was out of sync.
You can verify if it's your case with the date command in your terminal.

If it's actually out of sync try this:

~$ sudo hwclock -s

Hope it helps 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests