400-881-9892

文档中心

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

文档中心 互动课堂

About the Token Generation Instructions

    Token Generation

    1、Information Association

    The following information needs to be obtained:

    •  companyDomain: The enterprise domain (required).

    •  authKey: The enterprise key (required).

    •  roomId: The room ID (required).

    •  userId: The user ID (required).

    •  privilegeExpiredTs: A timestamp representing the number of seconds elapsed since January 1, 1970, at 00:00:00 UTC. For example, if you want the privilege to expire 10 minutes after the Token is generated, you should set privilegeExpiredTs to the current timestamp plus 600 (seconds). If the privilege should never expire, set this value to 0.

    For the acquisition of the enterprise domain and key, please refer to the enterprise details information in the Enterprise Management Console.

    2、AES Encryption

    Concatenate companyDomain, authKey, roomId, userId, and privilegeExpiredTs to form tokenString, and then perform AES encryption on tokenString.

    3、Objective-C Example

    1
    2
    3
    4
    5
    6
      #define kCompanyDomain @"talkcloud"#define kAuthKey @"abcd1234efg"
        NSString *roomId = @"1473793911 ";
        NSString *userId = @"ade123456 ";
        NSString *privilegeExpiredTs = @"0";
        NSString *tokenString = [NSString stringWithFormat:@"%@%@%@%@%@", kCompanyDomain, kAuthKey, roomId, userId, privilegeExpiredTs];
        NSString *token = AES(tokenString); //AES Encryption
    

    SDK Usage

    The TKRoomSDK supports joining a room using either the authKey method or the Token method

    1.  Joining the Room Using the authKey Method

    When calling the joinRoom interface to join a room, there is no need to include the token field in the roomparams parameter

    2.  Joining the Room Using the Token Method

    When calling the joinRoomEx interface to join a room, you need to include the token field in the roomparams parameter