Get participantId on connect and set room-password

Self-hosted JitsiMeet (docker)
Site with front on VueJS

On site I have authorized users with different rights.
I use IFrame API for create Jitsi room. Rooms creates fine, everything works fine.
Problem - users on site, that have group “admins” must be moderators in jitsi rooms. But… They can connect not first. And for security reasons I try set passwords to rooms.

In this I have 2 problems:

  1. Set moderator rights to specific user (even user not first in room)
  2. Set password to room

Current code:

      const apiMeet = new API('', options)
      apiMeet.executeCommand('displayName', user.value.nickName)
      apiMeet.executeCommand('avatarUrl', user.value.avatarUrl)
      apiMeet.executeCommand('subject', meetSubj.value)
      apiMeet.executeCommand('password', meetPass.value)

But… password not set. I try place command-password in onload option-section - no difference.

And I have property user.value.is_admin (bool).
How I set moderator rights for user when is_admin=true?
Docs have command grantModerator ( Commands | Jitsi Meet ), but for this I must have participantID.

I try this solution: How to get the participantId - #4 by Dibyajyoti_Prusty , but not works.

How I can solve this problems?

If you’re handing over users from your app to your Jitsi deployment, and not expected thing to visit the Jitsi site directly, then then cleanest solution really is to use JWT authentication – lib-jitsi-meet/ at master · jitsi/lib-jitsi-meet · GitHub

Anyone without a valid JWT will not be able to enter a room, and when you load Jitsi for your app users, you would generate a JWT token that already contains their display name and avatar URL.

As for moderator rights, you can use something like the following plugin to promote users to moderators based on the token content – prosody-plugins/token_affiliation at main · jitsi-contrib/prosody-plugins · GitHub

To answer your question specifically about running those IFrame commands, you’ll might need to wait for user to join the conference before setting password and changing subject. As for setting display name, you should use the userInfo option.


const options = {
    roomName: 'JitsiMeetAPIExample',
    // ...
    userInfo: {
        displayName: 'Firstname Lastname',
const api = new JitsiMeetExternalAPI(domain, options);
api.addListener('videoConferenceJoined', function() {
      api.executeCommand('avatarUrl', '');
      api.executeCommand('password', 'TopSecret');  // not the best. Users can see this in source.

Not sure how this will help you. Commands you run in IFrame API run as that connected user, and a user that is not moderator will not be allow grant themselves moderator access.

Thanks for help!

Not fine, but working solution.
Password generates for every room dinamically, but constant for every room.
I use “negative logic” - every next connected user will be moderator until connected user is not admin. For disable not-admin user moderation functions - disable interface elements for them via interfaceConfigOverwrite.TOOLBAR_BUTTONS in options.

Fihish code:

      if (user.value.is_admin) {
        toolbarButtons.value = [
          'microphone', 'camera', 'closedcaptions', 'desktop', 'fullscreen',
          'fodeviceselection', 'hangup', 'chat', 'recording',
          'livestreaming', 'etherpad', 'sharedvideo', 'settings', 'raisehand',
          'videoquality', 'filmstrip', 'invite', 'feedback', 'stats', 'shortcuts',
          'tileview', 'videobackgroundblur', 'download', 'help', 'mute-everyone',
          'e2ee', 'localrecording', 'security'
      } else {
        toolbarButtons.value = [
          'microphone', 'camera', 'closedcaptions', 'desktop', 'fullscreen',
          'fodeviceselection', 'hangup', 'chat',
          'settings', 'raisehand',
          'videoquality', 'shortcuts',
          'download', 'help'
      const options = {
        interfaceConfigOverwrite: {
          TOOLBAR_BUTTONS: toolbarButtons.value,
      const apiMeet = new API('', options)
      apiMeet.addListener('participantJoined', (data) => {
        if (!user.value.is_admin) {
      apiMeet.on('passwordRequired', function () {
        apiMeet.executeCommand('password', meetPass.value)
      apiMeet.addListener('participantRoleChanged', (data) => {
        if (data.role === 'moderator') {
          apiMeet.executeCommand('password', meetPass.value)
      apiMeet.executeCommand('displayName', user.value.nickName)
      apiMeet.executeCommand('avatarUrl', user.value.avatarUrl)

Everything works!

I understand that this is not fine and secure solution, but for basic usage is enough (now I create MVP of entire solution).

SOLVED :slight_smile:

Solved, but… I found a bug in Jitsi?

User1 is not admin
User2 is admin.

User1 connects first and get moderator rights - ok.
User2 (admin) connects next. On participantJoined User1 set moderator rights to User2.
User2 take notice about moderator rights.

Everything almost fine.

But User1 still have “Moderator” tab in settings and it works!

Is it bug in Jitsi?

If not - how hide moderator-tab in settings for ex-moderator user?

This does not revoke the moderator rights of User1.

Hmmm… User1 can revoke moderator rights for themself?

There is no such option in the UI. And there is no such option in the external API … So there is no such feature at the moment. This is possible though for other participants, no idea whether it will work for self lib-jitsi-meet/JitsiConference.js at 28436e572723331e9ed64d78d3ee458eacaa67bc · jitsi/lib-jitsi-meet · GitHub