Я пытаюсь получить доступ к хранилищу для моего проекта Firebase из бэкэнда, используя Firebase Admin SDK, но получаю следующую ошибку:
TypeError: gtoken_1.GoogleToken is not a constructor
Попытка загрузки нового файла service-account.json для моего проекта.
const admin = require('firebase-admin');
const serviceAccount = require('./service-account.json');
const credential = admin.credential.cert(serviceAccount);
admin.initializeApp({
credential,
storageBucket: 'k-test-eu.appspot.com',
});
const bucket = admin.storage().bucket();
bucket.getFiles().then(console.log);
Я получаю следующее сообщение об ошибке:
'(node:30714) UnhandledPromiseRejectionWarning: TypeError: gtoken_1.GoogleToken is not a constructor
at JWT.createGToken (/Users/namvu/Documents/29k/functions/node_modules/firebase-admin/node_modules/@google-cloud/common/node_modules/google-auth-library/build/src/auth/jwtclient.js:161:27)
at JWT.<anonymous> (/Users/namvu/Documents/29k/functions/node_modules/firebase-admin/node_modules/@google-cloud/common/node_modules/google-auth-library/build/src/auth/jwtclient.js:143:33)
at Generator.next (<anonymous>)
at /Users/namvu/Documents/29k/functions/node_modules/firebase-admin/node_modules/@google-cloud/common/node_modules/google-auth-library/build/src/auth/jwtclient.js:22:71
at new Promise (<anonymous>)
at __awaiter (/Users/namvu/Documents/29k/functions/node_modules/firebase-admin/node_modules/@google-cloud/common/node_modules/google-auth-library/build/src/auth/jwtclient.js:18:12)
at JWT.refreshTokenNoCache (/Users/namvu/Documents/29k/functions/node_modules/firebase-admin/node_modules/@google-cloud/common/node_modules/google-auth-library/build/src/auth/jwtclient.js:142:16)
at JWT.<anonymous> (/Users/namvu/Documents/29k/functions/node_modules/firebase-admin/node_modules/@google-cloud/common/node_modules/google-auth-library/build/src/auth/oauth2client.js:160:28)
at Generator.next (<anonymous>)
at /Users/namvu/Documents/29k/functions/node_modules/firebase-admin/node_modules/@google-cloud/common/node_modules/google-auth-library/build/src/auth/oauth2client.js:22:71
(node:30714) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 3)
(node:30714) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.