
SecretId 和 SecretKey 为敏感信息,为防止他人盗用,请妥善保管,谨防泄露。









const express = require('express');const app = express();const tencentcloud = require('tencentcloud-sdk-nodejs-intl-en');const CccClient = tencentcloud.ccc.v20200210.Client;const models = tencentcloud.ccc.v20200210.Models;const Credential = tencentcloud.common.Credential;const ClientProfile = tencentcloud.common.ClientProfile;const HttpProfile = tencentcloud.common.HttpProfile;app.get('/genUserSig', (req, res) => {// 从请求参数中读取 userId (例如: /genUserSig?userId=qiao123)// 调用方业务系统的唯一用户标识const userId = req.query.userId;if (!userId) {return res.status(400).send({error: 'Missing parameter: userId is required',});}let cred = new Credential('Your_SecretId', 'Your_SecretKey');let httpProfile = new HttpProfile();httpProfile.endpoint = 'ccc.intl.tencentcloudapi.com';let clientProfile = new ClientProfile();clientProfile.httpProfile = httpProfile;let client = new CccClient(cred, 'ap-singapore', clientProfile);let clientReq = new models.CreateUserSigRequest();let params = {SdkAppId: 20000000,Uid: userId,ExpiredTime: 3600,// 可选字段// ClientData: 'xxx',};clientReq.from_json_string(JSON.stringify(params));client.CreateUserSig(clientReq, function (err, response) {if (err) {console.log(err);res.status(500).send({error: err.message || 'Internal Server Error',});return;}res.send({userId: userId,userSig: response.UserSig,// ClientData是可选字段,但如果请求时指定了,需要一起返回给前端用于sdk的初始化// userClientData: params.ClientData,});});});
文档反馈