Browse SDKs · HarmonyOS
Platform
SDKsHarmonyOSEnterprise

Get call room credentials

Refresh or retrieve the media room token and gateway URL by room ID.

Copy

Use signalingGetTokenByRoomID() to refresh room credentials when joining an existing room or reconnecting to a session:

Code example

import sdk, { SignalingGetTokenByRoomIDReq, SignalingGetTokenByRoomIDResp } from '@openimsdk/imsdk';

const request: SignalingGetTokenByRoomIDReq = {
  roomID: roomID,
  userID: currentUserID,
  participant: participant,
};
const response: SignalingGetTokenByRoomIDResp = await sdk.signalingGetTokenByRoomID(request);
await mediaEngineJoin(roomID, response.token, response.liveURL);

Parameters

ParameterTypeRequiredDescription
roomIDstringYesTarget call room identifier.
userIDstringYesCurrent user ID joining or reconnecting to the room.
participantSignalingParticipantMetaDataYesCurrent user participant metadata.

Return value

Returns a Promise that resolves to a SignalingGetTokenByRoomIDResp object:

PropertyTypeDescription
tokenstringFresh token for joining the RTC media session.
liveURLstringMedia gateway server URL.

State changes after the call

The response returns credentials for the requested room; reuse the existing roomID from the request when configuring your media client. Only proceed to connect your media engine once non-empty token and liveURL values are obtained. If the query rejects, verify network connectivity and ensure the room has not already been dismantled.