Credential implementation provided to initializeApp() via the "credential" property failed to fetch a valid Google OAuth2
B

4

7

I have a NodeJS Firebase Function that uses firebase-admin sdk. It has been working alright since last year. In the last 2 weeks, the following error started showing in the log:

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: 404 page not found

Could it be an issue with the version of "firebase-admin": "^7.3.0" I am using?

Have anyone faced the same issue and can you offer some direction on what might have been the cause?

Bandit answered 11/8, 2021 at 5:56 Comment(3)
What version of NodeJS are you running? If you're using the Node.js 8 version is deprecated and this may be the reason of why you're getting this error. I suggest you to upgrade to a higher version.Dixiedixieland
You were right. The issue was with my NodeJS v8. Upgraded to node 10 works well for me.Bandit
Here is a suggested answer for this questions: Suggested AnswerSquiffy
K
4

This looks like a problem with NodeJS, the version 8 is no longer supported as per the documentation. Deployment of functions to the Node.js 8 runtime was disabled in the Firebase CLI on December 15, 2020 and that is most likely why you are facing the 404 error.

To migrate to a newer supported version of the NodeJS runtime, use the documentation.

Also, I do not suspect any issue with your firebase-admin version 7.3.0.

Krystinakrystle answered 12/8, 2021 at 8:29 Comment(2)
You were right. The issue was with my NodeJS v8. Upgraded to node 10 works well for me.Bandit
That's great! Thanks for accepting the answer. Please upvote it also.Krystinakrystle
B
2

I have the same error, but I was already on Node 12. Also, the function was running well for years and now is crashing due to this :/

The only solution that worked for me was to change auth to admin from default to explicit passing of service-account.json like is described here in docs https://firebase.google.com/docs/reference/admin/node/admin.credential#cert

Blanchard answered 22/8, 2021 at 7:8 Comment(1)
This link no longer works, do you have an example of this? I'm running into the same issue as you, Node 12Flocculate
N
0

For those who are deploying to Google Cloud Functions, requirements:

  • Node >= 10

Initialisation:

const functions = require('firebase-functions');
const admin = require('firebase-admin');

admin.initializeApp();
Nitpicking answered 24/5, 2022 at 7:6 Comment(0)
I
0

I had a similar issue. Node > 10

In my case, the error appears sometimes and not often - the reason I found is doing a bulk operation asynchronously. After adding await the calls became synchronous and this issue disappeared.

Irritant answered 14/8, 2023 at 7:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.