【发布时间】:2017-07-26 04:19:13
【问题描述】:
我正在开发一个使用 Twillios 可编程视频 API 的应用程序。
我是使用 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 自己的函数环境之外创建令牌时,是否有任何必需的依赖项或库?
非常感谢任何答案、建议或参考。
【问题讨论】:
-
你的意思是什么,你想将房间存储在其他变量中以供以后引用吗?你能说得清楚一点吗。
标签: javascript node.js twilio twilio-api