使用Firebase-Admin SDK帐户时如何解决凭证和令牌错误

时间:2019-01-20 23:57:51

标签: javascript firebase sdk admin

有关SDK Admin的快速问题。我在代码中对其进行了初始化,但是当我调用管理员功能时,它抱怨凭证和令牌,你知道这可能是由什么引起的吗?

var serviceAccount = require('../../../path to the actual json file);
admin.initializeApp({
    credential: admin
        .credential
        .cert(serviceAccount),
    databaseURL: 'https://<name of my database>.firebaseio.com'
});

然后我得到这个错误:

Error fetching user data: Error: Credential implementation provided to initializeApp() via the "credential" property failed to fetch a valid Google OAuth2 access token with the following error: "Failed to parse access token response: Error: Error while making request: incorrect header check. Error code: Z_DATA_ERROR".
    at FirebaseAppError.FirebaseError [as constructor] (error.js:39)
    at FirebaseAppError.PrefixedFirebaseError [as constructor] (error.js:85)
    at new FirebaseAppError (error.js:119)
    at firebase-app.js:121

关于如何解决此问题的任何想法?文件的路径正确。

0 个答案:

没有答案