I'm so close to that.
I wrote a cloud-based function that takes information sent from an Azure token to a Firebase custom mint token and sends that token back to the client.
The token is created correctly, but does not return on my HTTP request.
Unfortunately, the Firebase application is causing a timeout.
The execution of the function took 6,0002 ms, completed with the status: 'timeout'
I can not believe why this is so, therefore, this post. Is there something wrong with my code, or am I calling the HTTP request incorrectly?
Here is the log I get from the Firebase console.
Here is my code
exports.createFirebaseToken = functions.https.onRequest((req, res) => {
const uid = req.body.uid;
const additionalClaims = {
name: req.body.name,
email: req.body.email
};
const userCreationTask = admin.auth().updateUser(uid, additionalClaims).catch(error => {
if (error.code === 'auth/user-not-found') {
console.log(`Created user with UID:${uid}, Name: ${additionalClaims.name} and e-mail: ${additionalClaims.email}`);
return admin.auth().createUser({
uid: uid,
displayName: displayName,
email: email,
});
}
throw error;
console.log('Error!');
});
return Promise.all([userCreationTask]).then(() => {
console.log('Function create token triggered');
return admin.auth().createCustomToken(uid, additionalClaims).then((token) => {
console.log('Created Custom token for UID "', uid, '" Token:', token);
return token;
});
});
});
When I make this HTTP request, all I send is this JSON
, which looks like this:
parameters = [
"uid" : id,
"email" : mail,
"name" : name
]