glamorous-finland-74321
11/10/2025, 9:01 AM@router.get("/livekit/get-token")
async def get_livekit_token_endpoint(
request: Request,
user: User = Depends(require_invite),
):
print("get_livekit_token_endpoint", user)
from livekit import api
# Convert user model to dict and ensure all values are strings
# since with_attributes expects dict[str, str]
user_dict = user.model_dump()
user_attributes = {k: str(v) if v is not None else "" for k, v in user_dict.items()}
token = (
api.AccessToken(settings.livekit_api_key, settings.livekit_api_secret)
.with_identity(user.id)
.with_name(f"notbf-stream")
.with_metadata(json.dumps(user_attributes))
.with_grants(
api.VideoGrants(
room_join=True,
room="notbf-stream",
)
)
)
return {
"participantName": f"{token.identity}",
"participantToken": token.to_jwt(),
"roomName": "notbf-stream",
"serverUrl": settings.livekit_url,
}
how can I get the stuff from with_metadata()
when user connects to the Agent