I\'m so close with this one.
I have written a Cloud Function that takes information sent from an Azure token to custom mint a Firebase token and se
Cloud Functions triggered by HTTP requests need to be terminated by ending them with a send()
, redirect()
, or end()
, otherwise they will continue running and reach the timeout.
From the terminate HTTP functions section of the documentation on HTTP triggers:
Always end an HTTP function with
send()
,redirect()
, orend()
. Otherwise, your function might to continue to run and be forcibly terminated by the system. See also Sync, Async and Promises.After retrieving and formatting the server time using the Node.js moment module, the
date()
function concludes by sending the result in the HTTP response:const formattedDate = moment().format(format); console.log('Sending Formatted date:', formattedDate); res.status(200).send(formattedDate);
So, within your code, you could send the token back in the response with send()
, for example:
// ...
// Create a Firebase custom auth token.
return admin.auth().createCustomToken(uid, additionalClaims).then((token) => {
console.log('Created Custom token for UID "', uid, '" Token:', token);
res.status(200).send(token);
return token;
});
// ...