Twilio API_KEY_SECRET与控制台中的Twilio Auth Token相同吗?

时间:2017-01-20 00:37:39

标签: twilio jwt twilio-api

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

以下是生成Access令牌的NodeJS应用服务器代码。在以下凭证中,API_KEY_SECRET是必需的,我认为这与可以在Twilio console中找到的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);

2 个答案:

答案 0 :(得分:4)

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

您将使用在步骤1中创建的API密钥(API_KEY_SID)的秘密(API_KEY_SECRET),使用Twilio Helper Library生成访问令牌(ACCESS_TOKEN)

此处的详细说明 - Twilio Authorization - 参考步骤1,2,3,其示例用不同语言解释,包括Nodejs。

答案 1 :(得分:0)

Set<Integer> board = new HashSet<Integer>();
    for(int i = 0; i < scores.length; i++){
        board.add(Integer.valueOf(scores[i]));
    }
    List<Integer> finalBoard = new ArrayList<Integer>(board); 

    Collections.sort(finalBoard);

    int[] aliceRank = new int[alice.length];

    int aliceScore;
    int boardNo = 0;
    for(int i = 0; i < alice.length; i++){
        aliceScore = alice[i];

        for(int j = boardNo; j < finalBoard.size(); j++){
            if(aliceScore > finalBoard.get(boardNo)){
                continue;
            } else if(aliceScore <= finalBoard.get(j)){
                aliceRank[i] = finalBoard.size() - 
            }
        }

    }



    // Step 1 - Ranking the Scores to leader board
    Arrays.sort(scores);

    int[] rankBoard = new int[scores.length];
    for(int i = scores.length - 1; i >= 0; i--){
        rankBoard[scores.length - i - 1] = scores[i];
    }

    //Step 2 - Removing the duplicates
    Set<Integer> cleanBoard = new HashSet<Integer>();
    for 
    return output;
}