fierce-answer-55580
09/02/2025, 3:09 PMtall-airline-16756
09/02/2025, 3:10 PMtall-airline-16756
09/02/2025, 3:10 PMfierce-answer-55580
09/02/2025, 3:12 PMtall-airline-16756
09/02/2025, 3:13 PMLIVEKIT_API_KEY and LIVEKIT_API_SECRET are set up right in your environment or passed in properly.
• Missing or invalid video grants: Your token needs to have video grants with room_join set to true and the room field filled out.
• Token expiration: Tokens expire by default after 6 hours, so make sure yours hasn’t timed out.
Give these a quick look in your production setup, and hopefully, that’ll clear things up. If you’re still stuck, just let me know—I’m here to help!
Sources: replay/cloud_replay.twirp.go | protocol/unity_proto/UnityAPI.twirp.go | Authentication | LiveKit Docs | livekit-api/livekit/api/access_token.pyfierce-answer-55580
09/02/2025, 3:20 PMtall-airline-16756
09/02/2025, 3:21 PMfrom livekit.api.access_token import AccessToken
import datetime
token = AccessToken(api_key, api_secret)
token.with_ttl(datetime.timedelta(hours=1)) # This sets the token to expire in 1 hour
token.with_identity("user")
token.with_grants(VideoGrants(room_join=True, room="my-room"))
jwt_token = token.to_jwt()
The with_ttl method lets you specify how long the token should last using a datetime.timedelta object. If you don’t set a TTL, tokens will expire after 6 hours by default.
If you have any questions or want me to walk you through it, just let me know—I’m here to help!
Sources: Authentication | LiveKit Docs | packages/livekit-server-sdk/README.mdfierce-answer-55580
09/02/2025, 3:24 PMtall-airline-16756
09/02/2025, 3:24 PMfierce-answer-55580
09/02/2025, 3:30 PMtall-airline-16756
09/02/2025, 3:31 PM