Skip to content

Commit 6876b08

Browse files
Prefix token_source example files; pin SDK commit
Rename the per-type token source examples and shared helper to a token_source_ prefix so source filenames match their executable target names, and update the CMake source list, includes, and README references. Pin the README build instructions to client-sdk-cpp commit bbf6a41 and update the caching example comment to reference invalidate() now that force_refresh was dropped from the SDK API. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 93c960d commit 6876b08

8 files changed

Lines changed: 24 additions & 21 deletions

token_source/CMakeLists.txt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,19 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
# One executable per token source type. Each shares common.h for the logging
16-
# delegate and the connect/observe session loop.
15+
# One executable per token source type. Each shares token_source_common.h for
16+
# the logging delegate and the connect/observe session loop.
1717

1818
# Resolve the SDK lib directory so -llivekit_ffi is found at link time.
1919
get_filename_component(_lk_cmake_dir "${LiveKit_DIR}" DIRECTORY) # .../lib/cmake
2020
get_filename_component(_lk_lib_dir "${_lk_cmake_dir}" DIRECTORY) # .../lib
2121

2222
set(_token_source_examples
23-
token_source_literal literal.cpp
24-
token_source_endpoint endpoint.cpp
25-
token_source_sandbox sandbox.cpp
26-
token_source_custom custom.cpp
27-
token_source_caching caching.cpp
23+
token_source_literal token_source_literal.cpp
24+
token_source_endpoint token_source_endpoint.cpp
25+
token_source_sandbox token_source_sandbox.cpp
26+
token_source_custom token_source_custom.cpp
27+
token_source_caching token_source_caching.cpp
2828
)
2929

3030
list(LENGTH _token_source_examples _count)

token_source/README.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ disconnects.
1616

1717
| Example | Type | When to use |
1818
|---|---|---|
19-
| `literal.cpp` | `LiteralTokenSource` | You already have a URL + JWT (minted out of band, e.g. `lk token create`). The SDK consumes them as-is. |
20-
| `endpoint.cpp` | `EndpointTokenSource` | Recommended for production. The SDK POSTs request options to your backend token endpoint, which returns the URL + a fresh JWT. API keys stay server-side. |
21-
| `sandbox.cpp` | `SandboxTokenSource` | Local development only. Uses LiveKit Cloud's sandbox token server. Not for production. |
22-
| `custom.cpp` | `CustomTokenSource` | You have an internal auth/token system. Plug in your own async callback that returns credentials. |
23-
| `caching.cpp` | `CachingTokenSource` | A decorator that adds JWT-aware caching around any configurable source (endpoint/sandbox/custom) to cut down on fetch calls. |
19+
| `token_source_literal.cpp` | `LiteralTokenSource` | You already have a URL + JWT (minted out of band, e.g. `lk token create`). The SDK consumes them as-is. |
20+
| `token_source_endpoint.cpp` | `EndpointTokenSource` | Recommended for production. The SDK POSTs request options to your backend token endpoint, which returns the URL + a fresh JWT. API keys stay server-side. |
21+
| `token_source_sandbox.cpp` | `SandboxTokenSource` | Local development only. Uses LiveKit Cloud's sandbox token server. Not for production. |
22+
| `token_source_custom.cpp` | `CustomTokenSource` | You have an internal auth/token system. Plug in your own async callback that returns credentials. |
23+
| `token_source_caching.cpp` | `CachingTokenSource` | A decorator that adds JWT-aware caching around any configurable source (endpoint/sandbox/custom) to cut down on fetch calls. |
2424

2525
`LiteralTokenSource` is *fixed* (no per-call options); the others are
2626
*configurable* and accept
@@ -48,13 +48,16 @@ committed to source.
4848
The token source API is newer than the latest published SDK release, so build
4949
these examples against a **local SDK build** of the
5050
[`feature/token_source_api`](https://github.com/livekit/client-sdk-cpp/tree/feature/token_source_api)
51-
branch rather than a downloaded release.
51+
branch rather than a downloaded release. The commands below pin the branch to
52+
commit [`bbf6a41`](https://github.com/livekit/client-sdk-cpp/commit/bbf6a41fae42607ee19ff44ccddac786767b34e3)
53+
so the examples build against a known-good API; drop the `git checkout` of the
54+
hash to track the branch tip instead.
5255

5356
```bash
5457
# 1. Build and install the SDK from the feature branch.
5558
git clone https://github.com/livekit/client-sdk-cpp.git
5659
cd client-sdk-cpp
57-
git checkout feature/token_source_api
60+
git checkout bbf6a41fae42607ee19ff44ccddac786767b34e3
5861
git submodule update --init --recursive
5962
./build.sh release --bundle --prefix "$HOME/livekit-sdk-install"
6063

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
// configurable token source (endpoint, sandbox, or custom).
1919
//
2020
// Repeated fetches for the same request options reuse the cached token until it
21-
// nears expiry or a force-refresh is requested, cutting down calls to your
22-
// backend. This example wraps an EndpointTokenSource.
21+
// nears expiry or you call invalidate() to drop the cached credentials, cutting
22+
// down calls to your backend. This example wraps an EndpointTokenSource.
2323
//
2424
// Environment:
2525
// LIVEKIT_TOKEN_ENDPOINT Token endpoint URL
@@ -34,7 +34,7 @@
3434
#include <string>
3535
#include <utility>
3636

37-
#include "common.h"
37+
#include "token_source_common.h"
3838

3939
namespace {
4040

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
#include <iostream>
3737
#include <string>
3838

39-
#include "common.h"
39+
#include "token_source_common.h"
4040

4141
namespace {
4242

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
#include <string>
3535
#include <utility>
3636

37-
#include "common.h"
37+
#include "token_source_common.h"
3838

3939
namespace {
4040

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
#include <iostream>
3131
#include <string>
3232

33-
#include "common.h"
33+
#include "token_source_common.h"
3434

3535
namespace {
3636

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
#include <iostream>
3232
#include <string>
3333

34-
#include "common.h"
34+
#include "token_source_common.h"
3535

3636
namespace {
3737

0 commit comments

Comments
 (0)