
SecretId and SecretKey. For guide, see Access Key.
/loginTCCCAPI. The example code is in Node.js; for other languages, see CreateSDKLoginToken.// Version of tencentcloud-sdk-nodejs required to be 4.0.3 or laterconst tencentcloud = require('tencentcloud-sdk-nodejs');const express = require('express');const app = express();const CccClient = tencentcloud.ccc.v20200210.Client;app.use('/loginTCCC', (req, res) => {const clientConfig = {// Address to obtain secretId and secretKey: https://console.tencentcloud.com/cam/capicredential: {secretId: 'SecretId',secretKey: 'SecretKey'},region: 'ap-singapore',profile: {httpProfile: {endpoint: 'ccc.tencentcloudapi.com'}}};const client = new CccClient(clientConfig);const params = {SdkAppId: 1400000000, // Replace it with your own SdkAppIdSeatUserId: 'xxx@qq.com' // Replace it with the agent account};client.CreateSDKLoginToken(params).then((data) => {res.send({SdkURL: data.SdkURL})},(err) => {console.error('error', err);res.status(500);});})
/loginTCCC API implemented in step two to get SDKURL.function injectTcccWebSDK(SdkURL) {if (window.tccc) {console.warn('The SDK has been initialized. Please confirm whether the initialization is being executed repeatedly');return;}return new Promise((resolve, reject) => {const script = document.createElement('script');script.setAttribute('crossorigin', 'anonymous');// The DomId needs to be rendered into it. If it is filled in, there is no floating window, and the workspace is directly rendered into the specified dom element (XML)// To ensure the integrity of the workspace UI, the rendered Dom should have a minimum height of 480px and a minimum width of 760px// script.dataset.renderDomId = "renderDom";script.src = SdkURL;document.body.appendChild(script);script.addEventListener('load', () => {// JS SDK file loaded successfully. At this point, you can use the global variable "tccc"window.tccc.on(window.tccc.events.ready, () => {/*** TCCC SDK initialization succeeded. At this point, you can call out, listen to inbound events, and use other features.* Note ⚠️: Please ensure that the SDK is only initialized once* */resolve('Initialization succeeded')});window.tccc.on(window.tccc.events.tokenExpired, ({message}) => {console.error('Initialization failed', message)reject(message)})})})}// Request the interface implemented in step 2 /loginTCCC// Note ⚠️: The following is just a code example, it is not recommended to run directlyfetch('/loginTCCC').then(res => res.json()).then((res) => {const SdkURL = res.SdkURL; // Ensure that the SdkURL is returned by the request, otherwise, unpredictable errors may occur!return injectTcccWebSdk(SdkURL);}).catch((error) => {// Initialization failedconsole.error(error);})
Feedback