Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

299
Visualizações
TwiML app and Firebase throwing Unhandled promise rejection: Error: Could not load the default credentials

Context:

My app makes use of VoIP using TwiML, I store call records and additional data in Firebase. When a call is created, Twilio is a central point where the call gets created/cancelled. For this reason, when making a call I make use of Firebase to create a call entry in Firebase.


Looked for some documentation online for this issue, support or similar issues but came up short. The issue is quite simple:

Log output:

I see log output up to this message:

getting profile from

then get this error:

UnhandledPromiseRejectionWarning: Unhandled promise rejection: Error: Could not load the default credentials. Browse to https://cloud.google.com/docs/authentication/getting-started for more information. at GoogleAuth.getApplicationDefaultAsync (/var/task/node_modules/google-auth-library/build/src/auth/googleauth.js:180:19) at processTicksAndRejections (internal/process/task_queues.js:97:5) at async GoogleAuth.getClient (/var/task/node_modules/google-auth-library/build/src/auth/goo...


TwiML app code similar to Firebase Functions:

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);
}

Any idea what can cause this/why this occurs? Not finding much in the way of solutions online

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

The solution was a simple one, caused by an oversight.

Twilio automatically prepends "client:" to the event.From field. This I was attempt to find a document client:abcd1234... in firestore which didn't exists.

The error was however misleading, having nothing to do with incorrrect credentials but was infact a missing firestore document.


Possible solutions:

  1. Sanitize input:

Check if event.From contains "client:", if so call .split(":")[1] to get the ID or latter portion of the From parameter.

  1. Use Twilio's custom parameters sent from the client, which will be included in the payload object.

e.g. adding custom parameters like:

customParams: {
    "hello": "world",
    "another": "entry"
}

will then be available in the payload like like this:

  • payload.hello
  • payload.another
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda