1

I got some 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)\".

There are two likely causes: (1) your server time is not properly synced or (2) your certificate key file has been revoked.

To solve (1), re-sync the time on your server. To solve (2), make sure the key ID for your key file is still present at firebase project. If not, generate a new key file at service account setting.

When I try to use Firebase Admin SDK in Nodejs.

At my local computer it works, but when I try to use in AWS server, I got this error. Some tip?

Himanshu Bansal
  • 2,003
  • 1
  • 23
  • 46

2 Answers2

3

This is usually because your server clock is out of sync. You will need to adjust and sync the clock on your AWS VM instance. See Token must be a short-lived token and in a reasonable timeframe

Community
  • 1
  • 1
Hiranya Jayathilaka
  • 7,180
  • 1
  • 23
  • 34
  • Thanks for the solution, in my case I have a centos server in cloud and I used this article for solve the error: https://www.tecmint.com/set-accurate-server-time-in-centos/ – Gaalvarez Jan 26 '21 at 14:10
1

If you are on windows and developing on the local environment, You can solve it by just setting your computer clock time to set time automatically. Both timezone and time should be set to set automatically. At least that's the single thing that worked for me in dev mode.

Akah
  • 1,389
  • 14
  • 19