Description
Hi,
I'm not exactly sure where to post this, so please feel free to move it to the appropriate location if needed. This could be an issue with my code, the documentation, or something else.
I'm developing a Flutter application and I'm using the Firebase Functions sdk.
I recently came across the Firebase documentation page that explains how to invoke Firebase Functions. The information provided works well for Gen1 Functions, but it does not seem to work for Gen2 Functions.
The Gen2 function:
exports.getmuxvideotokentest = onCall({
region: "europe-west3",
timeoutSeconds: 60,
minInstances: 1,
maxInstances: 10,
concurrency: 100,
}, (req, res) => {
let token = "";
try {
const playbackId = req.get("playbackId");
let baseOptions = {
keyId: process.env.MUX_SIGNING_KEY,
keySecret: process.env.MUX_PRIVATE_KEY,
expiration: "1h"
};
token = JWT.signPlaybackId(playbackId, {...baseOptions, type: "video"});
} catch (e) {
console.log(e)
res.status(500).send("Token creation failed")
}
res.status(200).send(token);
});
The flutter call (works perfectly on Gen1 Functions):
final HttpsCallableResult<dynamic> res = await FirebaseFunctions.instanceFor(region: "europe-west3")
.httpsCallable("getmuxvideotokentest")
.call(<String, dynamic>{"playbackId": playbackId});
The problem:
{"error":{"message":"Bad Request","status":"INVALID_ARGUMENT"}}
Is there an alternative method to invoke Gen2 Functions, such as using HTTP requests, that I should be following? Any guidance or clarification on this topic would be greatly appreciated.