This message was deleted.
# helpdesk
s
This message was deleted.
p
hi Ram, you don’t need to tag individual people here, it just creates noise for the people you tag. We’re all here to help each other out 🙂
blob
sounds like you might not actually passing in a string to the token generator. How are you generating the token?
➕ 1
a
Hi lukasIO, Thank you for your reply. sure, i shall not tag individual. please find my code below
Copy code
const generateToken=(participantName: string, room: string)=>{

    let roomName: string = room;
    const at = new AccessToken(process.env.apiKey, process.env.secretKey, {
      identity: participantName,
    });
    at.addGrant({
      roomCreate : true, 
      roomJoin: true,
      room: roomName,
      canPublish: true,
      canSubscribe: true,
    }
  );

    const token = at.toJwt();
    return token;
}
p
thanks! can you add a
console.log(roomName, typeof roomName)
just before returning and post what that prints out?
a
Copy code
myRoom string
this is what i am getting in the console log
p
hm, that’s odd. and the token still displays
room: “blob”
? can you give it a try by hard coding the room name like so
Copy code
at.addGrant({
      roomCreate : true, 
      roomJoin: true,
      room: "myRoom",
      canPublish: true,
      canSubscribe: true,
    }
a
Copy code
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ2aWRlbyI6eyJyb29tSm9pbiI6dHJ1ZSwicm9vbSI6ImJsb2IiLCJjYW5QdWJsaXNoIjp0cnVlLCJjYW5TdWJzY3JpYmUiOnRydWV9LCJpYXQiOjE2OTM0NzQxNjksIm5iZiI6MTY5MzQ3NDE2OSwiZXhwIjoxNzU2NTQ2MTY5LCJpc3MiOiJBUElaWkZiRU5yN1A3QmEiLCJzdWIiOiJzZGZnIiwianRpIjoic2RmZyJ9.qI1jNV9MKWqqs16bTzeMDk53IhYV14Y_SmFqOPiS514
Same - here is the JWT generated
p
that’s really strange. which version of the server-sdk are you using? It would be great if you could share a .ts/.js file snippet that shows the behaviour in order to debug it further.
a
i have one question - even when i tried with some dummy apikey, token and server url i got some JWT token, which is also similar to above with "blob" room
Copy code
const generateToken=(participantName: string, grants: object)=>{

    const at = new AccessToken("wrong_key", "wrong_secret", {
      identity: "demo",
    });
    at.addGrant({
      roomCreate : true, 
      roomJoin: true,
      room: "myRoom",
      canPublish: true,
      canSubscribe: true,
    });

    const token = at.toJwt();
    return token;
}
this one also same result - and i am using
"livekit-server-sdk": "^1.2.6",
p
there must be something wrong somewhere else in your code, I just tried the same code you posted here with the latest livekit-server-sdk and it gives me the correct room name in the token
a
f
This code says "blob" here.
I don't remember the express stuff now, is it possible somehow it is hitting that code instead of the one in the controllers directory?
a
sure - i uploaded older version of code. i think there is some issue in my env. for some reason - the code is not updating in my env.
f
Oh it is this one, it is calling services.getToken here. which has the hard coded name "blob" ☝🏽
a
Sorry - my bad. apologies for the inconvenience. My env has issue. i think i found the issue. let me give a try now