JavaScript Client Always Calls Session Start

I’ve been using the Test Console (http://www.kaltura.com/api_v3/testme/index.php) to learn how to use the JavaScript API. With the test console I am able to successfully do a Session Start, and a Media Get call. For example, here’s a simple Session Start:

var cb = function (success, results){
  if(!success)
    alert(results);

  if(results.code && results.message){
    alert(results.message);
    return;
  }
  handleResults(results);
};
var config = new KalturaConfiguration(partnerId);
config.serviceUrl = "http://www.kaltura.com/";
var client = new KalturaClient(config);
var secret = "abcdefghijklmnopqrstuvwxyz";
var userId = "";
var type = null;
var partnerId = 1820941;
var expiry = null;
var privileges = null;
var result = client.session.start(cb, secret, userId, type, partnerId, expiry, privileges);

Then later on I’d like to make a Media Get call like so:

var cb = function (success, results){
  if(!success)
    alert(results);

  if(results.code && results.message){
    alert(results.message);
    return;
  }
  handleResults(results);
};
var config = new KalturaConfiguration(partnerId);
config.serviceUrl = "http://www.kaltura.com/";
var client = new KalturaClient(config);
var entryId = "1_ahxzxgyk";
var version = null;
var result = client.media.get(cb, entryId, version);

The problem is the client.media.get call is always reported (by Google Chrome Developer Tools Network tab) as going to:

http://www.kaltura.com//api_v3/index.php?service=session&action=start&...

Why is the client.media.get call getting stuck on a Session Start call?

FYI, this is in a PhoneGap / jQuery Mobile (and Google Chrome + Ripple) environment.

Hey @tyler_frankenstein - Since creating sessions requires inputing your credentials/secret keys, it’s actually not a good practice to use client side libraries (such the javascript client library) to generate sessions.
These type of API actions are better performed via backend APIs.
Also, if you have a player embedded on the page you’re making the calls from, and you already have a generated KS (Kaltura Session), or if the operations you’d like to run are anonymous read operations, you can also use the player’s built in client library.
See: http://player.kaltura.com/docs/index.php?path=api#kWidgetApi for more information.

Thank you for clarifying @Kalturian1 - I’ve created a sandbox module for Drupal, which uses the Drupal Services module to generate a KS string server side, and can be used by external apps to obtain a KS without exposing the credentials/secret keys client side. Here is the sandbox module for Drupal: https://www.drupal.org/sandbox/signalpoint/2390237

For example, in JavaScript one can do a POST to their Drupal site:

http://www.example.com/endpoint/kaltura/session_start.json

…and it will return to them a KS string. I’ve now successfully used this technique to properly call client.media.get to obtain an image from the Kaltura server, and display it in a mobile app, very cool!

For others, be careful with the JavaScript sample code output by http://www.kaltura.com/api_v3/testme/index.php when using session start, because the sample code suggests to place your secret key within the JavaScript, which isn’t good practice. Instead generate the KS string server side, and fetch it in your JS code.

This page/section was very helpful as well: http://knowledge.kaltura.com/introduction-kaltura-client-libraries#JavaScript