When authenticated via token, I cannot retrieve the list of entries

Hello :slight_smile:
I can authenticate with a SHA256 token, that has an ADMIN session type and these privileges: "“disableentitlement, list, download, sview, downloadasset, sviewplaylist”
However, whenever I call client.media_service.list (I am using the Ruby client), I receive the following response with 0 objects: #<Kaltura::KalturaMediaListResponse:0x000056265f005a10 @objects=nil, @related_objects=nil, @total_count=0>.
I can get single videos though with client.media_service.get(entry_id).
It seems to me it is pretty much an issue with permissions, but so far I haven’t been able to get around them…Any idea?
Thank you for your support in advance,
Anna

Hi @annacostalonga ,

I’d say something is wrong with the privileges value. Either the one passed when generating the session or the one set on the appToken object (appToken.sessionPrivileges).
First, check the sessionPrivileges value on the token and make sure it is what you expect to be. Secondly, if you have a token where the sessionType is ADMIN and you set the privileges to disableentitlement, you don’t need to set any additional privileges; a valid KS generated with that privilege can already perform any operation on that partner.

Hello Jess again,
I think I figured out why…I did not set the ks after starting the privileged session with the app_token.
So:

res = client.app_token_service.start_session(token_id, token_hash, session_user_id, session_type, expiry, session_privileges)
client.set_ks(res.ks)

I think that somehow the ks of the session was still the one set by the widget session? Could that be the case?
Now I can retrieve all the videos in my account.
Thanks a lot!
Cheers,
Anna

Hi @annacostalonga ,

As I noted in my reply to here https://forum.kaltura.org/t/creating-a-ks-with-an-apptoken-gives-an-invalid-app-token-hash-even-though-the-token-is-correct/8539/7:

res = client.app_token_service.start_session(token_id, token_hash, user_id, type, expiry, session_privileges);
# res.ks should now be assigned to the client so it can make requests

Cheers,

1 Like