AWS IVS 테스트 중 nodejs로 재생토큰 생성해 봤는데 혹시 나중에 참조할까 싶어 메모용..

const fs = require("fs");
const jwt = require('jsonwebtoken');


privateKey = fs.readFileSync('./private-key.pem');

expire = parseInt(new Date().getTime() / 1000, 10) + 60

payload = {
	"aws:channel-arn": "arn:aws:ivs:ap-northeast-2:538111149902:playback-key/vzVAAA2pkebk",
	"aws:access-control-allow-origin": "*",
	"exp": expire,
}

token = jwt.sign(payload, privateKey, { algorithm: 'ES384' });

url = "https://3fefaaab8240.ap-northeast-2.playback.live-video.net/api/video/v1/ap-northeast-2.538111149902.channel.86CWWWWOCiaSr.m3u8?token=" + token

console.log({url})

'Code snippets' 카테고리의 다른 글

AWS IVS 재생 토큰 생성  (0) 2022.06.29

+ Recent posts