firebase-admin-node icon indicating copy to clipboard operation
firebase-admin-node copied to clipboard

Error : '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: .".'

Open Rohan-SE opened this issue 1 year ago • 3 comments

[REQUIRED] Step 2: Describe your environment

  • Operating System version: Linux using from Chrome os
  • Firebase SDK version: firebase-admin : 12..2.0
  • Firebase Product: auth
  • Node.js version: V20.14.0
  • NPM version: 10.7.0

[REQUIRED] Step 3: Describe the problem

Facing this error: '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: .".' I set env also when I check it from console.log I got service account file values as object but still face this error when it hit that post request I got this error

Relevant Code:

that's my code: const admin =require ('firebase-admin') const { getAuth } = require('firebase-admin/auth'); try { admin.initializeApp()

} catch (error) { console.log(error) }

app.post('/api/auth/signup',async(req,res)=>{ try { const {email,password,username} = req.body; const user = await getAuth().createUser({ email, password, }) } catch(error){ console.log(error } }

Rohan-SE avatar Jul 15 '24 06:07 Rohan-SE

have the same issue

KennethicEnergy avatar Aug 08 '24 06:08 KennethicEnergy

Same for me, the code works on my local machine but I get the same error on my VPS, exact same env-vars and package versions on both systems (node 20.17.0 and firebase-admin 12.5.0). Has anyone solved this?

alexaanderk avatar Sep 14 '24 17:09 alexaanderk

I solved it, printed the error directly from "sendWithRetry" in utils/api-request.js and got a much more descriptive error: [errors]: [ Error: connect ETIMEDOUT redacted at createConnectionError (node:net:1648:14) at Timeout.internalConnectMultipleTimeout (node:net:1707:38) at listOnTimeout (node:internal/timers:583:11) at process.processTimers (node:internal/timers:519:7) { errno: -110, code: 'ETIMEDOUT', syscall: 'connect', address: 'redacted', port: 443 }, Error: connect ENETUNREACH redacted - Local (:::0) at internalConnectMultiple (node:net:1182:16) at Timeout.internalConnectMultipleTimeout (node:net:1712:5) at listOnTimeout (node:internal/timers:583:11) at process.processTimers (node:internal/timers:519:7) { errno: -101, code: 'ENETUNREACH', syscall: 'connect', address: 'redacted', port: 443 } ]

I found this stackoverflow question and tried turning off IPv6 and it now works. So I think the http client tried to use IPv6 even though the machine had no connection via IPv6 (idk how IPv6 works, but thats my assumption).

alexaanderk avatar Sep 17 '24 15:09 alexaanderk

Since it sounds like you were able to fix the issue, I will close this for now. Thanks!

lahirumaramba avatar Nov 05 '24 17:11 lahirumaramba