How I can verify my livekit keys?
# ask-ai
b
How I can verify my livekit keys?
t
Thanks for reaching out, Gopi. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
To verify your LiveKit keys, you'll want to validate the JSON Web Token (JWT) using your
LiveKit API Key
and
LiveKit API Secret
. This step helps ensure that the token was signed correctly, that the issuer (
iss
) matches your API key, and that the token is still valid. LiveKit makes this easier by providing built-in token verification methods in its server SDKs for Python, Ruby, Go, and Rust. These SDKs handle the cryptographic details securely and automate the process for you. For example, in Python, you can use the
TokenVerifier
class like this:
Copy code
from livekit.api import TokenVerifier

verifier = TokenVerifier(api_key="your_api_key", api_secret="your_api_secret")
claims = verifier.verify(jwt_token)
If you're working with a language that doesn’t have an official SDK, no worries! You can manually verify the JWT using a standard library that supports HMAC-SHA256 (HS256) signing. This involves decoding the token, checking the
iss
claim, verifying the expiration (
exp
), and making sure the signature is valid. Please feel free to reach out if you'd like help with a specific SDK or if you'd prefer guidance on manual verification. I'm here to help! Sources: livekit-api/tests/test_webhook.py | lib/livekit/token_verifier.rb | auth/verifier_test.go | webrtc-sys/libwebrtc/boringssl_prefix_symbols.txt | Mini tutorial: setting up a LiveKit Cloud project
b
ok, how to verify it using livekit cli?
t
The LiveKit CLI doesn’t have a specific command just for verifying keys, but I’d love to help you out! Could you share a bit more about what you’re aiming to do with the verification? For instance, are you trying to test token validity, check if an API key is working, or something else? Let’s figure this out together!
b
yes, I wanted to check whether api key is working
t
To help you check if your LiveKit API key is working using the CLI, you can try some simple actions that need authentication. Let’s walk through the steps together: 1. List Active Rooms:
Copy code
lk room list \
  --url <your-livekit-url> \
  --api-key <your-api-key> \
  --api-secret <your-api-secret>
If your credentials are correct, this will show you a list of active rooms. If not, you might see an authentication error, which is totally okay — we can troubleshoot that next! 2. Create a Token:
Copy code
lk token create \
  --api-key <your-api-key> \
  --api-secret <your-api-secret> \
  --join --room test-room --identity test-user \
  --valid-for 1h
If you get a token successfully, that’s a great sign your credentials are working just fine. 3. Set Default Project (Optional): To make things easier and avoid typing your credentials every time, you can set your project in the CLI like this:
Copy code
lk project add --api-key <your-api-key> --api-secret <your-api-secret> my-project
lk project set-default my-project
After that, just running:
Copy code
lk room list
will confirm your credentials are set up and working smoothly. If you run into any issues or have questions, please don’t hesitate to reach out — I’m here to help! Sources: README.md | cmd/server/commands.go | livekit-agents/livekit/agents/cli/cli.py