Mux JWT helper does not support playback_restriction_id
Closed this issue · 3 comments
According to step 4, https://docs.mux.com/guides/video/secure-video-playback#4-generate-a-json-web-token, the playback_restriction_id
can be added to the JWT claims, yet the Mux JWT helper does not accept a playback_restriction_id
anywhere.
How can I add playback_restriction_id
to the JWT signing process?
Hey @paul-uz,
Sorry you're right this isn't clear.
You should be able to set this in the params
hash, like in the example on this page: https://docs.mux.com/guides/video/secure-video-playback#5-sign-the-json-web-token-jwt
const { JWT } = require('@mux/mux-node');
const playbackId = ''; // Enter your signed playback id here
let baseOptions = {
keyId: '', // Enter your signing key id here
keySecret: '', // Enter your base64 encoded private key here
expiration: '7d' // E.g 60, "2 days", "10h", "7d", numeric value interpreted as seconds
};
const token = JWT.sign(playbackId, { ...baseOptions , type: 'video'});
const gifToken = JWT.sign(playbackId, {
...baseOptions,
type: 'gif',
params: { time: 10, playback_restriction_id: 'PLAYBACK_RESTRICTION_ID'},
})
Let me know if this works.
Thanks!
Hi @philcluff that seems to work.
I first tried added it to the baseOptions, but that didn't work. Adding it to params did the trick.
Could you please look at updating the documentation with this information?
Glad it worked for you, I've asked the team here to either update the docs and/or add this to the helper explicitly.
Thanks!