Skip to content
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

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

Closed
Rohan-SE opened this issue Jul 15, 2024 · 4 comments

Comments

@Rohan-SE
Copy link

[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
}
}

@KennethicEnergy
Copy link

have the same issue

@alexaanderk
Copy link

alexaanderk commented Sep 14, 2024

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
Copy link

alexaanderk commented Sep 17, 2024

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

@lahirumaramba
Copy link
Member

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

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

No branches or pull requests

5 participants