1
我正在開發一個使用Twillios可編程視頻API的應用程序。使用節點JS生成Twillio訪問令牌
我剛剛使用Node JS,但文檔相當簡單,但我仍然有幾個問題。
這裏是我引用的代碼。
const AccessToken = require('twilio').jwt.AccessToken;
const VideoGrant = AccessToken.VideoGrant;
// Used when generating any kind of tokens
const twilioAccountSid = 'ACxxxxxxxxxx';
const twilioApiKey = 'SKxxxxxxxxxx';
const twilioApiSecret = 'xxxxxxxxxxxx';
const identity = 'user';
// Create Video Grant
const videoGrant = new VideoGrant({
room: 'cool room'
});
// Create an access token which we will sign and return to the client,
// containing the grant we just created
const token = new AccessToken(twilioAccountSid, twilioApiKey, twilioApiSecret);
token.addGrant(videoGrant);
token.identity = identity;
// Serialize the token to a JWT string
console.log(token.toJwt());
在由Twillio,視頻授予我以爲是強制性的明確引用提供了這個具體的例子,但是這將意味着這個特定的令牌生成器,用戶只能輸入該名稱的房間。
我想知道是否有可能在配置令牌之前參考之前的。類似於身份是如何在輸出令牌之前輸入到函數中的變量。
此外,在Twillios自己的功能環境之外創建令牌時是否還有任何所需的依賴項或庫?
任何答案,建議或參考非常感謝。
您的觀點是什麼?您想將房間存儲在其他變量中以供日後參考嗎?你能更清楚的配偶嗎? –