【发布时间】:2021-12-16 16:38:18
【问题描述】:
上下文:
我的应用通过 TwiML 使用 VoIP,我将通话记录和其他数据存储在 Firebase 中。创建呼叫时,Twilio 是创建/取消呼叫的中心点。因此,在拨打电话时,我会使用 Firebase 在 Firebase 中创建通话条目。
在线查找有关此问题、支持或类似问题的一些文档,但没有找到。问题很简单:
日志输出:
我看到这条消息的日志输出:
从
获取个人资料
然后得到这个错误:
UnhandledPromiseRejectionWarning:未处理的承诺拒绝:错误:无法加载默认凭据。浏览至https://cloud.google.com/docs/authentication/getting-started 了解更多信息。在 GoogleAuth.getApplicationDefaultAsync (/var/task/node_modules/google-auth-library/build/src/auth/googleauth.js:180:19) 在 processTicksAndRejections (internal/process/task_queues.js:97:5) 在异步 GoogleAuth .getClient (/var/task/node_modules/google-auth-library/build/src/auth/goo...
TwiML 应用代码 类似于 Firebase 函数:
const AccessToken = require('twilio').jwt.AccessToken;
const VoiceGrant = AccessToken.VoiceGrant;
const VoiceResponse = require('twilio').twiml.VoiceResponse;
// Import the functions you need from the SDKs you need
const firebase = require("firebase-admin")
const firebaseConfig = {
apiKey: "",
authDomain: "",
databaseURL: "",
projectId: "",
storageBucket: "",
messagingSenderId: "",
appId: "",
measurementId: ""
};
// Initialize Firebase
console.log("initializing firebase")
const app = firebase.initializeApp(firebaseConfig);
exports.handler = async function(context, event, callback) {
console.log("Running make-call")
const from = event.From;
let to = event.to;
//...
console.log("getting profile from")
// exception is thrown at this line below
var callerProfileSnap = await firebase.firestore(app).collection("profiles").doc(from).get();
// originally had this, but attempted loading the app manually as "credentials" couldn't be loaded made me think this might be an issue
// var callerProfileSnap = await firebase.firestore().collection("profiles").doc(from).get();
// ... continuation of code
var voiceResponse;
callback(null, voiceResponse);
}
知道什么会导致这种情况/为什么会发生这种情况?在网上找不到太多解决方案
【问题讨论】:
标签: javascript node.js firebase twilio twilio-twiml