Twilio API_KEY_SECRET是否与控制台中的Twilio身份验证令牌相同?

use*_*776 6 twilio jwt twilio-api

我正在尝试使用Twilio Video,需要从我的应用程序服务器获取访问令牌(jwt)。

以下是生成访问令牌的NodeJS应用服务器代码。在下面的凭证中,API_KEY_SECRET是必需的,我认为这与可以在Twilio控制台中找到的Twilio Auth令牌相同。

我的理解正确吗?如果没有,我在哪里可以找到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);
Run Code Online (Sandbox Code Playgroud)

Sri*_*h A 5

当您创建 API 密钥(API_KEY_SID)时 - 您将看到密钥的秘密(API_KEY_SECRET),

您将使用您在步骤 1 中创建的 API 密钥 (API_KEY_SID) 的秘密 (API_KEY_SECRET) 来使用 Twilio 帮助程序库生成访问令牌 (ACCESS_TOKEN)

此处详细说明 - Twilio 授权- 请参阅步骤 1、2、3,它以不同语言(包括 Nodejs)的示例进行了解释。

  • 除此之外,您可以在此处的 Twilio 控制台中创建 API 密钥:https://www.twilio.com/console/dev-tools/api-keys (3认同)