The access to service [media->list] is forbidden

Can anyone help take a loot what is wrong with my NodeJS code? client.media.listAction returns error below. We use Kaltura SaaS.

“The access to service [media->list] is forbidden”

var kaltura = require(’./KalturaClient.js’);
var kalturaTypes = require(’./KalturaTypes.js’);
var vo = require(’./KalturaVO.js’)

var cb = function (results){
if(results){
console.log(results);
return;
}
}

var partnerId = 188XXXX;
var conf = new kaltura.KalturaConfiguration(partnerId);
conf.serviceUrl = “http://www.kaltura.com”;

var client = new kaltura.KalturaClient(conf);

var secret = “adminsecretinKMC”;
var userId = “myemailaddress”;
var type = kalturaTypes.KalturaSessionType.ADMIN;

var expiry = 100000;
var privileges = null;
client.session.start(cb, secret, userId, type, partnerId, expiry, privileges);

var filter = new vo.KalturaMediaEntryFilter();

var filterAdvancedSearch = new vo.KalturaMetadataSearchItem();
filterAdvancedSearch.type = 2; //kaltura.KalturaSearchOperatorType.SEARCH_OR;
filterAdvancedSearch.metadataProfileId = 31;

var filterAdvancedSearchItems = new vo.KalturaSearchCondition();
filterAdvancedSearchItems.field = “/[local-name()=‘metadata’]/[local-name()=‘MediaType’]”; // MediaType is the system name is Custom Data in KMC
filterAdvancedSearchItems.value = ‘1’;

filterAdvancedSearch.items = [filterAdvancedSearchItems];
filter.advancedSearch = filterAdvancedSearch;

client.media.listAction(function(results){console.log(results);
}, filter, null);

Did you ever resolve this? I just ran into it as well, and am wondering what I’m doing wrong.

Hello,

I’m not sure what the issue is in your case but in the code above, it is that setKs() is never called.
Should be something like:
var config = new KalturaConfiguration(partner_id);
config.serviceUrl = “https://www.kaltura.com/”;
var client = new KalturaClient(config);
client.session.start(function(success, ks) {
if (!success || (ks.code && ks.message)) {
console.log(‘Error starting session’, success, ks);
console.log(ks.message || ‘Unknown Error’)
} else {
client.setKs(ks);
}

}, “secrethash”,
"userid@kaltura.com",
KalturaSessionType.ADMIN,
partner_id)

Also take a look at developer.kaltura.com which is a good way to get started with the API.