Lib-jitsi-meet display name is undefined with JWT

Hi, in react app i am using the lib-jitsi-meet, where i make a connection with JWT and init a conference.
But for example if i listend to the ‘USER_JOINED’ event, every user who have joined is with _displayName: undefined.

So in one part of the app i am joining and listen to the ‘USER_JOINED’ event, on the other part of app i am joining the same room, but in the first side of the app where i listen, the displayName is undefined.
The strange thing is that if i open URL from my backend, which is something like that:
{jitsi_domain}/{room_name}?token={token}, the _displayName is OK.

Cant really someone help ?
This is what i am doing:
When the app loads i am checking a query parameter in the URL and acording to that i am redirecting to one component or to another one (2 components).
When the chosen componen is mounter i am making a jitsi connection object with that structure:

const connection = new window.JitsiMeetJS.JitsiConnection(null, token, {
    hosts: {
        domain: ...
        muc: conference. ...
    },
    serviceUrl: ..../http-bind,
    clientNode: ...
  });

I am attaching listeners for connection success and fail. And then call the “connect()” method. Everything connects succesfully.
In the listener for the successful connection i am making a conference object:

const conference = connection.initJitsiConference(
    roomName,
    {
        openBridgeChannel: true
    }
);

add listener to the “USER_JOINED” event and other listeners too,
then call “join()” method.

After that when i open the app on another tab/browser and again make the same things like above (with different token but joining same room). The “USER_JOINED” listener is triggered but some of the user properties are “undefined” like “_displayName” as i said.

When i join the same room but not from my App, from a URL returned from my backend team
somedomain/{roomName}?token={theToken} it opens a view similar to the jitsi-meet view, and then on my app i am seeing everyting for the user who have joined.

I am not sure but this may help.
I am using iframe API with jwt, and wanted to implement a single session per user.
What I was doing was videoConferenceJoined and then checking if same user was already logged in and if yes then log force first user to logout using hangup.by sending message to first user using sendEndpointTextMessage.
videoConferenceJoined was triggering but message could not be sent with error no channel opened or not enabled when openBridgeChannel was set to true, I tried using websockets same issue.
What i realized later was token authentication was triggered after videoConferenceJoined event,
Following trick worked , I used setTimeout to delay my executeCommand by 5 seconds and it worked fine. I spent almost 10 days figuring it out.
just check console logs, this may be issue

First, thanks for that you are trying to help.
Unfortunately i tried everything, timeouts etc etc etc…

The thing is that when i am on my app and someone joins the conference again from the app, the returned user in the 'USER_JOIN" listener have property - properties: {} , but when i join the conference from the URL given by the backend team i open a webpage i think powered by jitsi-meet, and on my app that property for that user is properties: { ee2e: true } or something like that (atm i am on the home computer).

@damencho or someone else from the staff, can you help please ?
For sure the things are not so simple as in the lib-jitsi-meet documentation.

  1. Create Connection object
    1.1 Add listeners
    1.2 Connect to the server
  2. Create Conference object
    2.1 Add listeners
    2.2 Join the conference

    I got the code of the old front end which we have to replace now with our custom react app. There they are using the “jitsi-meet” frontend and just have removed some functionalities from there.
    I changed some of their old configs for the connection (host, domain etc). And now i succesfully connect to our jitsi server. And again if i join from our react app to a conference and listen for the ‘USER_JOIN’ event, every user using the ‘jitsi-meet’ have a display name, but if i join from our app every user is with displayName: undefined…
    I am trying to check how the things are happening in the ‘jitsi-meet’ but there are so many things there and cant understand everything, i am just with couple months experience…

lib-jitsi-meet is not aware of the JWT. Jitsi Meet updates the local participant name if there is a token.

@saghul Well the displayName is in the token, so how can i get that display name from the token and then update the local participant with the setDisplayName method ?
Also on the modified ‘jitsi-meet’ front end which i talked about, the start screen where we can enter display name like the normal ‘jitsi-meet’ is removed. So when i go to url:
some_domain/{room_name}?token={token} everything works fine. And the displayName is the one from the token.

Dont know what to do more… I see all participants are saved in the redux store but they have their nicknames from the tokens. The thing is how do you get that displayName from the token…
The most strange thing is that for the ‘lib-jitsi-meet’ documentation there is absolutely no information for cases like that. I saw there were a topic about that problem also a year ago or so but again no help from the staff…
For sure to get the displayName correctly from the token the things are not simple as it looks like from the ‘lib-jitsi-meet’ documentation.

  1. create connection object and connect()
  2. create conference object, add listner for the USER_JOIN and join()

You need to extract the display name from jwt and set it https://github.com/jitsi/lib-jitsi-meet/blob/351612321002ff6244fdf6be84f6188fe39ed458/JitsiConference.js#L884

1 Like

It is extracted in jitsi-meet and set in lib-jitsi-meet. The extraction is here: https://github.com/jitsi/jitsi-meet/blob/master/react/features/base/jwt/middleware.js#L142

2 Likes

OK, now i understand it. Thank you very much !

He/She can get the _identity of the JitsiParticipant object which includes the token context. I have added it to lib-jitsi-meet a while ago: https://github.com/jitsi/lib-jitsi-meet/pull/933

The docs can be found here: https://github.com/jitsi/lib-jitsi-meet/blob/master/doc/tokens.md#access-token-identifiers--context

1 Like

Thanks, Paul! LoL I have no recollection of reviewing that PR!

1 Like