I'm working in Unity and see that some operations ...
# ask-ai
b
I'm working in Unity and see that some operations on participants require permissions to update their own metadata. How to I set these permissions?
✅ 1
t
Thanks for reaching out, Mat. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks — I’m responding to your question about how to let participants update their own metadata from a Unity client. Short answer: • You grant that ability when you generate the participant’s access token on your server by setting
canUpdateOwnMetadata: true
in the VideoGrant. This cannot be set from the Unity client. What to do (server-side): 1. When creating the JWT access token, add a VideoGrant that includes: ◦
room
(the room name) if you want to scope the grant ◦
roomJoin: true
(so the participant can join) ◦
canUpdateOwnMetadata: true
(this enables updating their own metadata) Example (Node.js):
Copy code
import { AccessToken, VideoGrant } from 'livekit-server-sdk';

const at = new AccessToken('api-key', 'secret-key', { identity: 'user123' });

const videoGrant = new VideoGrant({
  room: 'my-room',
  roomJoin: true,
  canUpdateOwnMetadata: true,
});

at.addGrant(videoGrant);
const token = await at.toJwt();
Client (Unity) notes: • The Unity client uses the JWT you generated to connect. Once connected with a token that includes
canUpdateOwnMetadata
, the participant can call the client SDK method to update their metadata (methods vary by SDK version—look for
setMetadata()
/
setAttributes()
or equivalent in your Unity SDK). • If the token lacks
canUpdateOwnMetadata
, attempts to update metadata will be rejected by the server. If you’d like, tell me: • Which server language you’re using (Node, Go, Python, etc.) and I’ll provide a concrete token-generation snippet for that language. • Which Unity SDK version or method name you’re using so I can point to the exact client call to update metadata. Sources: Server-side | livekit/livekit_composite | DeepWiki | client-sdk-unity | livekit/livekit_composite | DeepWiki, with interactive elements
b
My Unity client is creating the room, but does not have a separate token for joining the room since it's already there. How does it gain the ability to update its metadata? Can the token for creating the room include that permission?
t
Thanks — I’m addressing your question about a Unity client that creates a room and doesn’t use a separate join token: can that same token include the permission to update its own metadata? Yes. The permission is included in the JWT access token (the VideoGrant) you issue on the server. Whether that token is used to create the room or to join it, as long as the token contains
canUpdateOwnMetadata: true
the participant will be allowed to update their own metadata after connecting. Key points: • Permissions are enforced by the token presented when the client connects. The server does not care whether the token was also used to create the room — only the grants inside the token matter. • Include
canUpdateOwnMetadata: true
in the VideoGrant when you generate the token used by the Unity client. • Once the Unity client connects with that token, it can call the client SDK method to update its metadata (e.g.,
setMetadata()
/
setAttributes()
depending on your Unity SDK version). If you want, tell me: • Which server language you’re using (Node, Go, Python, etc.) so I can give a concrete code snippet for generating that token. • Which Unity SDK method/version you have, and I’ll point to the exact client call to update metadata., with interactive elements