28 lines
501 B
Python
28 lines
501 B
Python
from livekit import api
|
|
|
|
from core.config import settings
|
|
|
|
|
|
def generate_join_token(
|
|
user_id: str,
|
|
group_id: str,
|
|
can_publish: bool
|
|
):
|
|
|
|
token = api.AccessToken(
|
|
settings.LIVEKIT_API_KEY,
|
|
settings.LIVEKIT_API_SECRET
|
|
)
|
|
|
|
token.with_identity(user_id)
|
|
|
|
token.with_grants(
|
|
api.VideoGrants(
|
|
room=group_id,
|
|
room_join=True,
|
|
can_publish=can_publish,
|
|
can_subscribe=True
|
|
)
|
|
)
|
|
|
|
return token.to_jwt() |