How to connect to Firebase by Firebase Admin again

2019-02-26 05:02发布

Currently, I am using Firebase Admin SDK to connect a Firebase database in a NodeJS server side application.

But I do not find an option to connect Firebase via proxy settings, or it can detect my system HTTP_PROXY environment variable.

When I run the node script by node index.js, and got some timeout messages like this(I know in my work network, I can not connect to Firebase directly).

Error: Credential implementation provided to initializeApp() via the "credential
" property failed to fetch a valid Google OAuth2 access token with the following
 error: "connect ETIMEDOUT 216.58.200.237:443".                                 
    at ....erver\node_modules\firebase-adm
in\lib\firebase-app.js:74:23                                                    
    at process._tickCallback (internal/process/next_tick.js:103:7)                                                                                             

I also use browser to access the firebase console via proxy, it works.

But how to resolve this issue in NodeJS server side scripts?

1条回答
成全新的幸福
2楼-- · 2019-02-26 05:56

This error also happens if the date and time on your host machine where you run NodeJS process is not set right. Make sure to keep the server time synced.

The full error message: 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, generatea new key file at https://console.firebase.google.com/project/_/settings/serviceaccounts/adminsdk.

查看更多
登录 后发表回答