400-881-9892

文档中心

官方文档,可查阅产品介绍、快速入门、用户指南、开发指南、API参考、SDK参考、帮助等信息。

文档中心 互动课堂

About the Token Generation Instructions

    Token Generation

    1、Information Association

    The following information is required:

    • appId: The enterprise domain (required)
    • authKey: The enterprise key (required)
    • thirdRoomid: The instant room number (required)
    • userId: The user ID (required)
    • ts: The current timestamp (required)
    • expireTs: The room expiration time (in seconds) (required)

    For information on obtaining the company domain and key, please check the company details in the enterprise management backend

    2、AES encryption

    tokenString = "appId=" + appId + "&thirdRoomId=" + thirdRoomid + "&userId=" + userId + "&ts=" + ts + "&expireTs=" + expireTs;AES encryption using the AESUtil class interface provided by the SDK. The sample code is as follows.

    Method Example:

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
        RoomParams roomParams = new RoomParams();
        UserParams userParams = new UserParams();
        String thirdRoomid = "1122334455";  //Third-party Room Id
        String appId = "appId" ;  //Enterprise Domain
        String authkey = "authkey";  //Enterprise key
        String userId = "22223333";
        String ts = String.valueOf(new Date().getTime());
        long expireTs = 3600;   // Room Expiration Time
        String originalText = "appId=" + appId + "&thirdRoomId=" + account +  "&userId=" + userId + "&ts=" + ts + "&expireTs=" + expireTs;
        SecretKey restoredKey = AESUtil.getKeyFromString(authkey);
        String token = AESUtil.encrypt(originalText, restoredKey,authkey);
    
    SDK Usage
    • TKRoomSDK supports joining the room using both the joinRoom method and the joinRoomEx method Pass the enterprise domain appId in the init method, and then call joinRoom or joinRoomEx to enter the room