Discussions
Livekit room no video appearing
last month by Sameer Abbas
I'm using the following token permissions (this is what I suspect the issue is, but I'll dump additional config below just in case it's useful):
token = api.AccessToken(os.getenv('LIVEKIT_API_KEY'), os.getenv('LIVEKIT_API_SECRET')) \
.with_identity("identity") \
.with_name("name") \
.with_grants(api.VideoGrants(
room_join=True,
room=ctx.room.name,
can_publish = True,
can_publish_data = True,
can_subscribe = True,
)).to_jwt()
Here's how I create the session token :
url = "https://api.liveavatar.com/v1/sessions/token"
payload = {
"mode": "CUSTOM",
"avatar_id": avatar_id,
"livekit_config": {
"livekit_url": os.getenv("LIVEKIT_URL"),
"livekit_room": ctx.room.name,
"livekit_client_token": token
}
}
headers = {
"accept": "application/json",
"content-type": "application/json",
"X-API-KEY": api_key
}
response = requests.post(url, json=payload, headers=headers)
console.print(response.json(), style="bold green")
session_token = response.json()['data']['session_token']
session_id = response.json()['data']['session_id']
This works and I get a valid session_id. I use the session token to start the session. That also works perfectly (however the agent doesn't subscribe video)
url = "https://api.liveavatar.com/v1/sessions/start"
headers = {
"accept": "application/json",
"authorization": f"Bearer {session_token}"
}
response = requests.post(url, headers=headers)
For what it's worth, here's how I close the session:
url = "https://api.liveavatar.com/v1/sessions/stop"
payload = {
"session_id": session_id,
"reason": "USER_DISCONNECTED"
}
headers = {
"accept": "application/json",
"content-type": "application/json",
"X-API-KEY": api_key
}
response = requests.post(url, json=payload, headers=headers)
The creation, starting and stopping requests run without any errors, however the liveavatar agent doesn't seem to be publishing video to the room.