keySid is required
Closed this issue · 0 comments
Hi team,
Here is the API which i have used to get a Twilio token:
it gives me the error
{
"message": "keySid is required",
"name": "Error",
"stack": "Error: keySid is required\n at new AccessToken (/var/task/node_modules/twilio/lib/jwt/AccessToken.js:22:19)\n at exports.handler (/var/task/handlers/ZFf1504208d01f27af6e8f37acfb451400.js:4:15)\n at exports.handler (/var/task/node_modules/enigma-lambda/index.js:310:10)\n at exports.handler (/var/task/enigma.js:17:9)\n at Runtime.handleOnceNonStreaming (file:///var/runtime/index.mjs:1173:29)"
}
Here is the My code:
const generateToken = async (userName, tokenType, roomId) => {
setLoading(true);
let keySid = "SKe4356c1579ec928f6833e7420197b0c5";
let url = ${baseUrlTwilioToken}?identity=${userName}&roomID=${roomId}&keySid=${keySid}
;
console.log("token_url", url);
fetch(url, {
method: "GET",
headers: {
"Content-Type": "application/x-www-form-urlencoded",
},
// body: requestBody,
})
.then((response) => {
return response.json();
})
.then((responseJson) => {
setLoading(false);
console.log("generateToken res=", responseJson);
if (tokenType == "customerToken") {
setCustomerToken(responseJson.token);
_onConnectButtonPress();
} else {
setAdminToken(responseJson.token);
_onConnectButtonPress();
}
})
.catch((err) => {
setLoading(false);
console.log("Error", err);
Alert.alert("Alert", "Something went wrong!");
});
};
Please let me know How I can resolve this issue.Also please share an example to create a Twilio token
Thanks &Regards