Room Code Authentication
Room Codes are 100ms generated short codes, representing a Room ID and Role combination. Room codes not only simpify authentication, they can also be used to generate Room Links.
Room Code Authentication Basics
- When using Room Codes, it eliminates the need to generate auth token at your end to join a room.
- If you're using 100ms Prebuilt solution, Prebuilt inherently takes care of generating the auth token using room codes.
- When building a custom UI, you need to make an additional SDK API call
getAuthTokenByRoomCode
to generate the auth token.
Join rooms with room codes for custom UI
When building a custom UI and using room codes to generate room links, you can also use room codes to power authentication to join room without setting up an auth token server at your end.
Create Room Codes
Room codes can be made available in two ways:
For Rooms created on 100ms dashboard, a room code gets generated for every role in the room by default.
Retrieve role specific room code
-
No-Code
-
Select a room from Room page on 100ms Dashboard and click on "Join Room"
-
Copy room code for the role you want to authenticate
-
-
Programmatically,
- From the Room Link that you generate. For instance, you can retrieve room code from a custom room link
https://<your-template-subdomain>.app.100ms.live/meeting/<room-code>
- Alternatively, you can use Get Room Code API to retrieve the room code for the role joining the room.
- From the Room Link that you generate. For instance, you can retrieve room code from a custom room link
Get auth token using room codes
Once you have a role specific room code, call the SDK function getAuthTokenByRoomCode
with the retrieved room code. This function retrieves the auth token that is required to join the room.
Sample Code
You can use these code snippets to get auth token from room code.
const authToken = await hmsActions.getAuthTokenByRoomCode({ roomCode }); try { await hmsActions.join({ userName, authToken }); } catch (e) { console.error(e); }