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

See original GitHub issue
  • Operating System version: Windows 10
  • Firebase SDK version: no SDK used
  • Library version: firebase-admin@6.4.0
  • 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");

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:14 (2 by maintainers)

github_iconTop GitHub Comments

5reactions
EitanK96commented, Dec 18, 2019

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 ?

3reactions
hiranya911commented, Jan 8, 2019

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Firebase Admin failed to fetch a valid Google OAuth2 access ...
Started a clean app and had an issue where I couldn't even install firebase-admin . With a bit of digging I noticed that...
Read more >
Admin Authentication API Errors | Firebase - Google
Here is a full list of the error codes and descriptions, ... auth/invalid-id-token, The provided ID token is not a valid Firebase ID...
Read more >
Using OAuth 2.0 for Server to Server Applications | Authorization
With some Google APIs, you can make authorized API calls using a signed JWT directly as a bearer token, rather than an OAuth...
Read more >
Get OAuth 2.0 tokens | Apigee X - Google Cloud
Does not require the Authorization header, however the client ID of the registered client app must be supplied in the request. When refreshing...
Read more >
Authentication API Explorer - Auth0
OAuth2 Access Token. Send a valid Access Token in the Authorization header, using the Bearer authentication scheme. An example is the Get User...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found