I’m getting a 401 when my web app is trying to con...
# ask-ai
c
I’m getting a 401 when my web app is trying to connect to the room. I made sure the API KEY and SECRET are properly populated though. What am I missing
t
Thanks for reaching out, Guillaume. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
I'm sorry to hear you're encountering a 401 error when connecting to a LiveKit room. This usually points to an authentication hiccup, but don’t worry—we can work through it together! Here are some common reasons and helpful steps to get things back on track: • Invalid or malformed token: Please make sure your token is generated correctly using your API key and secret, and that it includes the right room name, participant identity, and permissions. • Expired token: It’s a good idea to check if the token has expired. If so, you might want to adjust the expiration time when generating the token. • Incorrect permissions: Double-check that your token has all the necessary permissions like
roomJoin
,
canPublish
, and
canSubscribe
. • Duplicate participant identity: Remember, each participant should have a unique identity. If your setup allows reconnections, make sure the participant isn’t already connected before trying to join again. If you’re creating tokens on the server side, it’s worth reviewing your logic to confirm the signing and payload are structured properly. Please feel free to reach out if you’d like a hand with token generation or want to debug this together—I’m here to help! Sources: Web and mobile frontends | LiveKit Docs | lib/src/core/room.dart | Diagnosing Connection Errors with Connection Test Utility | Authentication | LiveKit Docs | src/pages/api/connection_details.ts