作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试使用 Twilio Video,我需要从我的应用服务器获取访问 token (jwt)。
下面是生成访问 token 的 NodeJS 应用服务器代码。在下面的凭证中,API_KEY_SECRET 是必需的,我认为这与可以在 Twilio console 中找到的 Twilio Auth token 相同。 .
我的理解正确吗?如果没有,我在哪里可以找到 API_KEY_SECRET ?
var AccessToken = require('twilio').AccessToken;
// Substitute your Twilio AccountSid and ApiKey details
var ACCOUNT_SID = 'accountSid';
var API_KEY_SID = 'apiKeySid';
var API_KEY_SECRET = 'apiKeySecret';
// Create an Access Token
var accessToken = new AccessToken(
ACCOUNT_SID,
API_KEY_SID,
API_KEY_SECRET
);
// Set the Identity of this token
accessToken.identity = 'example-user';
// Grant access to Conversations
var grant = new AccessToken.ConversationsGrant();
grant.configurationProfileSid = 'configurationProfileSid';
accessToken.addGrant(grant);
// Serialize the token as a JWT
var jwt = accessToken.toJwt();
console.log(jwt);
最佳答案
当您创建 API key (API_KEY_SID)时 - 您将看到 key 的 secret (API_KEY_SECRET),
您将使用您在步骤 1 中创建的 API key (API_KEY_SID) 的 secret (API_KEY_SECRET) 来使用 Twilio 帮助程序库生成访问 token (ACCESS_TOKEN)
详细解释在这里 - Twilio Authorization - 引用步骤 1,2,3,它以不同语言的示例进行解释,包括 Nodejs。
关于twilio - Twilio API_KEY_SECRET 是否与控制台中的 Twilio 身份验证 token 相同?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41754225/
我正在尝试使用 Twilio Video,我需要从我的应用服务器获取访问 token (jwt)。 下面是生成访问 token 的 NodeJS 应用服务器代码。在下面的凭证中,API_KEY_SEC
我是一名优秀的程序员,十分优秀!