I want to send an Extension PubSub Message
I’m able to use that endpoint copy pasting JWT token printed in console when testing my extension frontend. Now I want to create a JWT from my EBS and use it to use the same endpoint. I’m always getting error 403 JWT could not be verified.
Reading from docs
if I’m not wrong I need to create a JWT with this structure:
{
"exp": at least 1 hour from now(),
"user_id": my twitch id,
"role": "external"
}
Then signing this with my extension secret located here (it is Base64)
and “using your JWT library of choice”.
I’m using this since is in C++ and is header only library:
So this is the code I’m using to create the token:
auto token = jwt::create()
.set_type("JWT")
.set_expires_at(std::chrono::system_clock::now() + std::chrono::seconds{ 3600 })
.set_payload_claim("user_id", jwt::claim(std::string("MY TWITCH ID")))
.set_payload_claim("role", jwt::claim(std::string("external")))
.sign(jwt::algorithm::hs256{ TWITCH_EXT_SECRET}); //<--string of base64 secret from ext confing
and finally using it into request header
request->addHeader("Authorization", "Bearer "+token);
Where am I wrong?