Class TokenSource
- Namespace
- LiveKit
Factory for the built-in ITokenSource implementations. The concrete implementations are private; obtain them through the factory methods and work with the returned ITokenSourceFixed or ITokenSourceConfigurable.
public static class TokenSource
- Inheritance
-
TokenSource
- Inherited Members
Methods
Custom(CustomTokenFunction)
Delegates connection-detail retrieval to a user-supplied async function. Use this when your app already has its own token-fetching code (custom auth flow, cached tokens, etc.).
public static ITokenSourceFixed Custom(TokenSource.CustomTokenFunction customTokenFunction)
Parameters
customTokenFunctionTokenSource.CustomTokenFunction
Returns
DevelopmentTokenServer(string)
Convenience Endpoint(string, IEnumerable<StringPair>) preconfigured for LiveKit Cloud development token servers. Intended for development and testing only — see https://docs.livekit.io/frontends/build/authentication/sandbox-token-server/.
public static ITokenSourceConfigurable DevelopmentTokenServer(string tokenServerId)
Parameters
tokenServerIdstring
Returns
Endpoint(string, IEnumerable<StringPair>)
Posts a JSON request to a token-server endpoint and returns the parsed ConnectionDetails. The body is built from per-call TokenSourceFetchOptions (room name, participant info, agent dispatch, etc.). Use for production token servers — see https://docs.livekit.io/frontends/build/authentication/endpoint/.
public static ITokenSourceConfigurable Endpoint(string endpointUrl, IEnumerable<StringPair> headers)
Parameters
endpointUrlstringheadersIEnumerable<StringPair>
Returns
Literal(string, string)
Returns a fixed server URL and participant token. Suitable when credentials are pregenerated (e.g. via the LiveKit CLI or LiveKit Cloud project page).
public static ITokenSourceFixed Literal(string serverUrl, string participantToken)
Parameters
Returns
SandboxTokenServer(string)
[Obsolete("Use TokenSource.DevelopmentTokenServer instead")]
public static ITokenSourceConfigurable SandboxTokenServer(string sandboxId)
Parameters
sandboxIdstring