How to programmatically set an initial room password?

I would like to prefill the password field for a room with a (random) password.
I looked into the code, but need some hint, where to start. Or is there any solution already available?
Thanks in advance.

1 Like

I suggest moving this to the Developers forum category.

Sorry.

Something like this will set the password for the room when someone starts the meeting and new joiners will have the same password set automatically (they’ll see the ‘enter password’ box flash up for a second, or so)…

meetAPI = new JitsiMeetExternalAPI("meet.jit.si", options);
setTimeout(() => {
          meetAPI.addEventListener('passwordRequired', () => {
            meetAPI.executeCommand('password', '$password');
          });
          meetAPI.addEventListener('videoConferenceJoined', (response) => {
            meetAPI.executeCommand('password', '$password');
          });
}, 10);

I use the above in a WordPress page that does some additional validation to ensure the member is logged-in to the site and authorised to access the meeting. The password is there to prevent an interloper joining. I use PHP to generate the random password in variable $password that stays the same throughout each day. I also do some checks comparing the current date with the date the page was loaded so people can’t leave the page open overnight and then try to join the following day with an out-of-date password.

The timeout in the code is good practice to prevent you trying to set an event listener before the API is ready.

Does that help?

Andy

1 Like