Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

298
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda