LiveKit C++ Client SDK v1.4.0
Real-time audio/video/data SDK for C++
Loading...
Searching...
No Matches
livekit::LiteralTokenSource Class Referencefinal

Token source that returns credentials you already created yourself. More...

#include <token_source.h>

Inheritance diagram for livekit::LiteralTokenSource:
Collaboration diagram for livekit::LiteralTokenSource:

Public Member Functions

std::future< Result< TokenSourceResponse, TokenSourceError > > fetch () override
 Fetch connection credentials.
 

Static Public Member Functions

static std::unique_ptr< LiteralTokenSourcecreate (std::string server_url, std::string participant_token)
 Create a token source from a static server URL and participant token.
 
static std::unique_ptr< LiteralTokenSourcecreate (std::function< std::future< Result< TokenSourceResponse, TokenSourceError > >()> provider)
 Create a token source from an async provider that returns full credentials.
 

Detailed Description

Token source that returns credentials you already created yourself.

Choose this when your app manually handles token creation/retrieval and you want the SDK to consume those credentials as-is ("literal" workflow). This class is ideal for quick prototypes, tests, and custom flows where you do not want the SDK to issue token-generation requests.

Member Function Documentation

◆ create() [1/2]

static std::unique_ptr< LiteralTokenSource > livekit::LiteralTokenSource::create ( std::function< std::future< Result< TokenSourceResponse, TokenSourceError > >()>  provider)
static

Create a token source from an async provider that returns full credentials.

Use this overload when credentials are produced outside the SDK but fetched lazily (for example, from your own cache or secure storage).

Note
This is still a fixed source: the provider takes no parameters and cannot be influenced by TokenRequestOptions. If you need a configurable source whose callback receives request options and can re-fetch on demand, use CustomTokenSource instead.
Parameters
providerAsync provider that returns full connection credentials.
Returns
A fixed token source backed by provider.

◆ create() [2/2]

static std::unique_ptr< LiteralTokenSource > livekit::LiteralTokenSource::create ( std::string  server_url,
std::string  participant_token 
)
static

Create a token source from a static server URL and participant token.

Each fetch call returns the same credentials.

Parameters
server_urlWebSocket URL of the LiveKit server.
participant_tokenJWT access token for the participant.
Returns
A fixed token source that returns the provided credentials.

◆ fetch()

std::future< Result< TokenSourceResponse, TokenSourceError > > livekit::LiteralTokenSource::fetch ( )
overridevirtual

Fetch connection credentials.

Returns
Future resolving to connection details or an error.

Implements livekit::TokenSourceFixed.


The documentation for this class was generated from the following file: