반응형

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 (60 minutes) and in a reasonable timeframe. Check your iat and exp values in the JWT claim.)". 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 https://console.firebase.google.com/iam-admin/serviceaccounts/project. If not, generate a new key file at console.firebase.google.com/project/_/settings/serviceaccounts/adminsdk.  

 

AWS EC2에 노드JS 서버를 올려서 푸시 서비스를 사용하고 있는데 어느 순간 푸시를 보낼 때마다 위와 같은 메세지가 뜨면서 푸시 서비스가 제대로 작동하지 않았다. 위에 의심되는 원인이 나열되어있듯이 나의 문제는 (1)번에 해당했다. 

내가 서버의 시간을 실수로 전혀 다른 시간으로 변경하면서, 푸시를 위해 파이어베이스 인증하는 과정에서 OAUTH 토큰의 유효 시간 체크에 대한 문제가 발생한 것이었다. 이 문제는 다시 서버의 시간을 정상적으로 돌리면서 해결되었다.

위와 같은 문제가 발생했을 때 서버의 시간을 확인하여 실제 시간과 오차가 많이 발생하지 않는지 확인해보도록 한다.

 

반응형

+ Recent posts