2
votes
var admin = require("firebase-admin");
var serviceAccount = require("service_account.json")

admin.initializeApp({
  credential: admin.credential.cert(serviceAccount),
  databaseURL: "https://******.firebaseio.com"
});

Returns:

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: invalid_grant (Invalid JWT: Token must be a short-lived token and in a reasonable timeframe)". The most likely cause of this error is using a certificate key file which has been revoked. Make sure the key ID for your key file is still present at https://console.firebase.google.com/iam-admin/serviceaccounts/project. If not, generate a new key file at https://console.firebase.google.com/project/_/settings/serviceaccounts/adminsdk.

The service_account and Key ID are present.

1
Server time was not synced. This thread was helpful in resolving, stackoverflow.com/questions/41712965/…user3288414
I'll make sure to add this case to the error message for an upcoming release so that future developers don't come across this issue. Thank you for reporting it! I'm glad you got it all figured out.jwngr

1 Answers

0
votes

The same incident happened to me. I have a structure that admin is nodejs, client is android and ios. This happened to me when i tried to run in my local host then i moved admin to heroku and it solved.