Skip to content

RoomServiceClient::createRoom returns 401 "invalid token" against self‑hosted/cloud LiveKit #48

Description

@arafat-mutahar

SDK version
agence104/livekit-server-sdk 1.3.4 (path install from this repo)
PHP 8.2
Laravel 11 app, using the SDK directly
Environment
Env vars:
LIVEKIT_URL=myServerurl.com
LIVEKIT_API_KEY=APILAy*******
_API_SECRET=*************** # redacted, but matches server config
Minimal code to reproduce

use Agence104\LiveKit\RoomServiceClient;
use Agence104\LiveKit\RoomCreateOptions;
$client = new RoomServiceClient(    'myServerurl.com',    getenv('LIVEKIT_API_KEY'),    getenv('LIVEKIT_API_SECRET'));
$opts = (new RoomCreateOptions())->setName('testRoomFromSdk')->setEmptyTimeout(10)->setMaxParticipants(4);
$room = $client->createRoom($opts);
var_dump($room);

Actual behavior
The call fails with 401:
Client error: POST myServerurl.com/twirp/livekit.RoomService/CreateRoom resulted in a 401 Unauthorized response: invalid token: <JWT...> //
What I’ve already checked
I copied the JWT token generated by sdk to postman
when call API first time return 401 Unauthorized response: invalid token
when call API second time return 200 success response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions