How to pass KS token to the java service classes?

I’m trying to create a live stream entry for which I need to pass the Kaltura session.

I found a sample code in the below link (click on the Test console tab. And select the livestream service from the dropdown. click on Java and click show code example). And was trying to follow along. But the Kaltura version (18.0.1) I use doesn’t support this style.

Kaltura - Test Me Console

Maven dependency used:


Is anyone aware of how to pass the Kaltura session to the service class in java? Appreciate your help!

Setting up the java configuration:

Configuration config = new Configuration();
Client client = new Client(config);

Generating the kaltura session using Java:

String session = client.generateSessionV2(“some admin secret", “some email id",
SessionType.ADMIN , partnerId, expiry, “some privileges”);

Trying to create a live stream entry using java:

LiveStreamEntry liveStreamEntry = new LiveStreamEntry();
liveStreamEntry.setName(“Webcast Tutorial”);
liveStreamEntry.setDescription(“This is a test webcast”);
LiveStreamService.AddLiveStreamBuilder result = LiveStreamService.add(liveStreamEntry, SourceType.LIVE_STREAM);

Here is the sample code from Python way of doing the same:
Generating ks token from python

def client_for_admin(username, privileges):
kaltura_config = KalturaConfiguration(“partner id")
kaltura_config.serviceUrl = “
client = KalturaClient(kaltura_config)
ks = client.session.start(
“admin secret",
“partner id",
return client

client = ks.client_for_admin(config.admin_email, “”)

Generating live stream using python
live_stream_entry = KalturaLiveStreamEntry() = “Webcast Tutorial”
live_stream_entry.description = “This is a test webcast”
live_stream_entry.mediaType = KalturaMediaType.LIVE_STREAM_FLASH
live_stream_entry.dvrStatus = KalturaDVRStatus.ENABLED
live_stream_entry.dvrWindow = 60
live_stream_entry.sourceType = KalturaSourceType.LIVE_STREAM
live_stream_entry.adminTags = “kms-webcast-event,vpaas-webcast”
live_stream_entry.pushPublishEnabled = KalturaLivePublishStatus.DISABLED
live_stream_entry.explicitLive = KalturaNullableBoolean.TRUE_VALUE
live_stream_entry.recordStatus = KalturaRecordStatus.PER_SESSION
result = client.liveStream.add(live_stream_entry, KalturaSourceType.LIVE_STREAM); // livestream is called from the client which has the kaltura session.


Basically you need to configure your KalturaConfiguration instance to use the KS.

Then we have the requests you want to make. I would advice you to have a look at this file on how to use the API services to send a request:

It seems nowadays we’re using Builder creational classes to build requests. Then we send them using this class:
import com.kaltura.client.APIOkRequestsExecutor;

I could be wrong here, but I made it work doing something simple like listing media with a certain name.

Hi @kp_vishnu ,

Kaltura - Test Me Console was deprecated quite a while ago.
Please use instead.

It includes a code generator for all supported clients, including Java. For example, have a look at this action:

To see the client initialisation code, check the Show setup checkbox.

As @pnts-se correctly wrote, once you’ve generated the KS, you need to assign it to the client object using:


Here’s a full example (as per the above):

    public static Client generateKalturaClient() {
        Configuration config = new Configuration();
        Client client = new Client(config);
        try {
            String session = client.generateSessionV2(
                  86400, "");
        } catch (Exception e) {
            System.out.println("Failed to start Kaltura session");
        return client;