Server Integration
The application server determines the device and role for the current session, requests short-lived connection credentials from the Tange platform, and securely delivers them to the device.
Authentication
The signing method is the same as Tange Cloud OpenAPI server-side signing. See 服务端API接口签名算法Demo.
Request Connection Credentials
Only the connection credential API uses the https://api-tirtc.tange365.com domain:
role_id is required. The application server must first obtain the role ID for this session from the console or OpenAPI.
POST https://api-tirtc.tange365.com/v1/token/aichat
Content-Type: application/json
Authorization: TGV1-HMAC-SHA256 ...
X-Tg-App-Id: {AppId}
{
"device_id": "DEMO_DEVICE_01",
"role_id": "role_xxx"
}Response:
{
"code": 0,
"msg": "ok",
"data": {
"peer_id": "whips://aichat?device_id=DEMO_DEVICE_01&role_id=role_xxx",
"token": "v1.{payload}.{signature}"
}
}For complete details, see Server API.
Deliver Credentials to the Device
After obtaining the peer_id and token from the platform, your server should send them to the device via a secure channel. The device only needs these two values and must never hold the server signing secrets.
{
"type": "aichat_join",
"device_id": "DEMO_DEVICE_01",
"role_id": "role_xxx",
"peer_id": "whips://aichat?device_id=DEMO_DEVICE_01&role_id=role_xxx",
"token": "v1.{payload}.{signature}"
}Security recommendations:
- Never log full tokens.
- Use
peer_idandtokenas soon as possible to avoid expiration. - Implement business logic to reject, queue, or end existing sessions if a device requests multiple simultaneous sessions.