Class TokenVerifier
- Namespace
- Livekit.Server.Sdk.Dotnet
- Assembly
- LivekitApi.dll
Helper to verify the integrity of a token.
public class TokenVerifier
- Inheritance
-
TokenVerifier
- Derived
- Inherited Members
Constructors
TokenVerifier(string, string, TimeSpan?)
Creates a verifier for tokens signed with the given API key and secret.
public TokenVerifier(string apiKey = null, string apiSecret = null, TimeSpan? leeway = null)
Parameters
apiKeystringAPI key the tokens must be issued by; the
LIVEKIT_API_KEYenvironment variable when omitted.apiSecretstringAPI secret the tokens must be signed with; the
LIVEKIT_API_SECRETenvironment variable when omitted.leewayTimeSpan?Clock tolerance applied to the token lifetime; DefaultLeeway when omitted.
Exceptions
- ArgumentException
The key or the secret is missing, or the secret is shorter than 32 bytes.
Methods
Verify(string)
Validates the signature, the issuer and the lifetime of a token and returns its claims.
public ClaimsModel Verify(string token)
Parameters
tokenstringThe JWT to verify.
Returns
- ClaimsModel
The claims of the token.
Exceptions
- SecurityTokenException
The token has a wrong signature or issuer, is expired or is not valid yet.
- ArgumentException
The token is not a well-formed JWT (
SecurityTokenMalformedException).