Creates the short-lived administrative tokens used by LiveKit service calls.
Every service call signs its own token carrying only the grants that call needs, so nothing here hardcodes a universal "admin everything" grant:
iex> client = LiveKit.Client.new!(url: "http://localhost:7880", api_key: "k", api_secret: "s")
iex> {:ok, jwt} = LiveKit.Auth.service_token(client, video_grant: %LiveKit.Grants.Video{room_list: true})
iex> is_binary(jwt)
trueTokens are valid for 600 seconds. This module deliberately knows nothing
about HTTP; LiveKit.Twirp combines it with the transport.
Summary
Functions
@spec service_token( LiveKit.Client.t(), keyword() ) :: {:ok, String.t()} | {:error, LiveKit.Error.t()}
Signs a service token for a client.
Options
:video_grant,:sip_grant,:agent_grant- individual grant structs.:grants- keyword list ofvideo:,sip:and/oragent:grants; a convenient shape for service modules that pass grants through.:identity- optional identity, encoded assub.:ttl- lifetime in seconds. Defaults to600.:clock- zero-arity function returning Unix seconds, for tests.
At least one grant is required.
Examples
iex> client = LiveKit.Client.new!(url: "http://localhost:7880", api_key: "k", api_secret: "s")
iex> {:ok, _jwt} = LiveKit.Auth.service_token(client, grants: [video: %LiveKit.Grants.Video{room_admin: true}])
iex> {:error, error} = LiveKit.Auth.service_token(client, [])
iex> error.type
:authentication
@spec service_token_ttl() :: pos_integer()
The lifetime of service tokens, in seconds.
Examples
iex> LiveKit.Auth.service_token_ttl()
600