Hello!
I am trying to make an extension that requires configuration, I have set the “Required Configurations” field in Extensions Capabilities (current value is: this_is_a_test)…
In my config javascript file, in the onAuthorized event, I send the auth.token to my EBS, which I can confirm that I receive succesfully. When the user click on “Submit” in the config.html, I send an AJAX request to my EBS and I have to send the PUT request https://dev.twitch.tv/docs/extensions/reference#set-extension-required-configuration … but this is where I am stuck. It looks like I can’t sign the JWT token properly, I am using https://github.com/auth0/node-jsonwebtoken to sign it, this is my code to sign the token:
jwt.sign({
"exp": Math.floor(Date.now() / 1000) + (60 * 60),
"user_id": payload.user_id,
"role": "external"
}, "my-secret-key");
FYI: I did console.log(payload) and console.log(payload.user_id) to make sure it is a valid payload and user_id.
It returns a signed token and when I try to send it in the header, I get {“code”:401,“status”:“authentication failed”}
I modified a little bit my code (changed client ID, secret, etc…):
const signed = jwt.sign({
"exp": Math.floor(Date.now() / 1000) + (60 * 60),
"user_id": payload.user_id,
"role": "external"
}, "sOmESecReT=");
require("request")({
url: "https://api.twitch.tv/extensions/s0m3cl1entid/0.0.1/oauth_receipt?channel_id=" + payload.channel_id,
method: "PUT",
headers: {
"Authorization": "Bearer " + signed,
"Client-Id": "s0m3cl1enTid"
},
json: {
"required_configuration": "this_is_a_test"
}
}, function(err, res) {
console.log(err, res.body);
});
Anyone know what I am missing here ? I even tested with Postman and still no luck. I can confirm that I can decode my signed token using jwt.decode.
Thanks