diff --git a/Editor/TokenSourceComponentConfigEditor.cs b/Editor/TokenSourceComponentConfigEditor.cs index 03650d98..581af79c 100644 --- a/Editor/TokenSourceComponentConfigEditor.cs +++ b/Editor/TokenSourceComponentConfigEditor.cs @@ -25,12 +25,12 @@ public override void OnInspectorGUI() EditorGUILayout.PropertyField(serializedObject.FindProperty("_token")); break; - case TokenSourceType.Sandbox: + case TokenSourceType.Development: EditorGUILayout.HelpBox( - "Use this for development to create tokens from a sandbox token server. " + - "\nWARNING: ONLY USE THIS OPTION FOR LOCAL DEVELOPMENT, SINCE THE SANDBOX TOKEN SERVER NEEDS NO AUTHENTICATION.", + "Use this for development to create tokens from a development token server. " + + "\nWARNING: ONLY USE THIS OPTION FOR LOCAL DEVELOPMENT, SINCE THE DEVELOPMENT TOKEN SERVER NEEDS NO AUTHENTICATION.", MessageType.Info); - EditorGUILayout.PropertyField(serializedObject.FindProperty("_sandboxId")); + EditorGUILayout.PropertyField(serializedObject.FindProperty("_tokenServerId")); DrawConnectionOptions(); break; diff --git a/README.md b/README.md index 81af3049..005cf88c 100644 --- a/README.md +++ b/README.md @@ -137,11 +137,11 @@ To help getting started with tokens, use `TokenSourceComponent.cs` with a `Token #### 1. Literal Use this to pass a pregenerated server URL and token. Generate tokens via the [LiveKit CLI](https://docs.livekit.io/frontends/build/authentication/custom/#manual-token-creation) or from your [LiveKit Cloud](https://cloud.livekit.io/) project's API key page. -#### 2. Sandbox -For development and testing. Follow the [sandbox token server guide](https://docs.livekit.io/frontends/build/authentication/sandbox-token-server/) to enable your project's sandbox and get the sandbox ID. Optional connection fields (room name, participant name, agent name, etc.) can be configured in the inspector — leave blank for server defaults. +#### 2. Development +For development and testing. Follow the [development token server guide](https://docs.livekit.io/frontends/build/authentication/sandbox-token-server/) to enable your project's development token server and get the token server ID. Optional connection fields (room name, participant name, agent name, etc.) can be configured in the inspector — leave blank for server defaults. #### 3. Endpoint -For production. Point to your own token endpoint URL and add any required authentication headers. Uses the same connection options as Sandbox. See the [endpoint token generation guide](https://docs.livekit.io/frontends/build/authentication/endpoint/). +For production. Point to your own token endpoint URL and add any required authentication headers. Uses the same connection options as Development. See the [endpoint token generation guide](https://docs.livekit.io/frontends/build/authentication/endpoint/). #### Usage @@ -186,7 +186,7 @@ yield return fetch; var details = fetch.Result; // Configurable sources accept TokenSourceFetchOptions per call: -ITokenSourceConfigurable configurable = new TokenSourceSandbox(""); +ITokenSourceConfigurable configurable = new TokenSourceDevelopment(""); // or: new TokenSourceEndpoint("https://your.token-server/api/token", headers); var configurableFetch = configurable.FetchConnectionDetails(new TokenSourceFetchOptions { RoomName = "lobby" }); diff --git a/Runtime/Scripts/TokenSource/TokenSource.cs b/Runtime/Scripts/TokenSource/TokenSource.cs index 9c9ba09e..91ab2e56 100644 --- a/Runtime/Scripts/TokenSource/TokenSource.cs +++ b/Runtime/Scripts/TokenSource/TokenSource.cs @@ -184,13 +184,20 @@ private static string NullIfEmpty(string value) => string.IsNullOrEmpty(value) ? null : value; } + + [Obsolete("Use TokenSourceDevelopment instead")] + public class TokenSourceSandbox : TokenSourceDevelopment + { + public TokenSourceSandbox(string sandboxId) : base(sandboxId) {} + } + /// - /// Convenience preconfigured for LiveKit Cloud sandbox token servers. + /// Convenience 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 class TokenSourceSandbox : TokenSourceEndpoint + public class TokenSourceDevelopment : TokenSourceEndpoint { - public TokenSourceSandbox(string sandboxId) : base("https://cloud-api.livekit.io/api/v2/sandbox/connection-details", new[] { new StringPair { key = "X-Sandbox-ID", value = sandboxId } }) {} + public TokenSourceDevelopment(string tokenServerId) : base("https://cloud-api.livekit.io/api/v2/sandbox/connection-details", new[] { new StringPair { key = "X-Sandbox-ID", value = tokenServerId } }) {} } } \ No newline at end of file diff --git a/Runtime/Scripts/TokenSource/TokenSourceComponent.cs b/Runtime/Scripts/TokenSource/TokenSourceComponent.cs index ebd104d6..31f630db 100644 --- a/Runtime/Scripts/TokenSource/TokenSourceComponent.cs +++ b/Runtime/Scripts/TokenSource/TokenSourceComponent.cs @@ -10,7 +10,7 @@ namespace LiveKit /// /// MonoBehaviour wrapper that builds an from an inspector-assigned /// ScriptableObject. To skip the asset entirely, instantiate - /// , , , + /// , , , /// or directly at runtime. /// public class TokenSourceComponent : MonoBehaviour @@ -34,8 +34,8 @@ public void Awake() switch (_config.TokenSourceType) { - case TokenSourceType.Sandbox: - _tokenSource = new TokenSourceSandbox(_config.SandboxId); + case TokenSourceType.Development: + _tokenSource = new TokenSourceDevelopment(_config.TokenServerId); break; case TokenSourceType.Endpoint: diff --git a/Runtime/Scripts/TokenSource/TokenSourceComponentConfig.cs b/Runtime/Scripts/TokenSource/TokenSourceComponentConfig.cs index 28f20a5d..896e1030 100644 --- a/Runtime/Scripts/TokenSource/TokenSourceComponentConfig.cs +++ b/Runtime/Scripts/TokenSource/TokenSourceComponentConfig.cs @@ -1,13 +1,14 @@ using System; using System.Collections.Generic; using UnityEngine; +using UnityEngine.Serialization; namespace LiveKit { public enum TokenSourceType { Literal, - Sandbox, + Development, Endpoint } @@ -27,14 +28,15 @@ public class TokenSourceComponentConfig : ScriptableObject [SerializeField] private string _serverUrl; [SerializeField] private string _token; - // Sandbox fields - [SerializeField] private string _sandboxId; + // Development fields + [FormerlySerializedAs("_sandboxId")] + [SerializeField] private string _tokenServerId; // Endpoint fields [SerializeField] private string _endpointUrl; [SerializeField] private List _endpointHeaders; - // Shared connection options (Sandbox + Endpoint) + // Shared connection options (Development + Endpoint) [SerializeField] private string _roomName; [SerializeField] private string _participantName; [SerializeField] private string _participantIdentity; @@ -50,8 +52,8 @@ public class TokenSourceComponentConfig : ScriptableObject public string ServerUrl => _serverUrl; public string Token => _token; - // Sandbox - public string SandboxId => _sandboxId?.Trim('"'); + // Development + public string TokenServerId => _tokenServerId?.Trim('"'); // Endpoint public string EndpointUrl => _endpointUrl; @@ -70,7 +72,7 @@ public class TokenSourceComponentConfig : ScriptableObject public bool IsValid => _tokenSourceType switch { TokenSourceType.Literal => !string.IsNullOrEmpty(ServerUrl) && ServerUrl.StartsWith("ws") && !string.IsNullOrEmpty(Token), - TokenSourceType.Sandbox => !string.IsNullOrEmpty(SandboxId), + TokenSourceType.Development => !string.IsNullOrEmpty(TokenServerId), TokenSourceType.Endpoint => !string.IsNullOrEmpty(EndpointUrl), _ => false }; diff --git a/Samples~/Agents/README.md b/Samples~/Agents/README.md index a7cf76eb..c7ab9bbe 100644 --- a/Samples~/Agents/README.md +++ b/Samples~/Agents/README.md @@ -20,9 +20,9 @@ The app is configured to connect to the LiveKit homepage agent by default, which To switch from the default agent to your own, you first need a LiveKit agent to speak with. For a no-code setup, use the [Agent Builder](https://docs.livekit.io/agents/start/builder/). For more customization, try our starter agent for [Python](https://github.com/livekit-examples/agent-starter-python), [Node.js](https://github.com/livekit-examples/agent-starter-node), or [create your own from scratch](https://docs.livekit.io/agents/start/voice-ai/). -Second, you need a token server. For development, the easiest option is the sandbox token server: enable it from your project's Options on the Settings page in LiveKit Cloud and copy the sandboxId. +Second, you need a token server. For development, the easiest option is the development token server: enable it from your project's Options on the Settings page in LiveKit Cloud and copy the token server ID. -Then create a new TokenSoureComponentConfig asset for your sandbox and reference it in the scene on the `TokenSourceComponent` script instead of the `HomepageAgent.asset`: +Then create a new TokenSoureComponentConfig asset for your development token server and reference it in the scene on the `TokenSourceComponent` script instead of the `HomepageAgent.asset`: ### Common sample package