How to connect to Firebase by Firebase Admin against a proxy?

不羁岁月 提交于 2019-12-30 11:14:17

问题


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:


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.



来源:https://stackoverflow.com/questions/41712965/how-to-connect-to-firebase-by-firebase-admin-against-a-proxy

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!