Third Light Developer Exchange

Code and templating community forum for developers and software integrators

You are not logged in.

Announcement

If you wish to join the Developer Exchange, please contact your account manager - this is to avoid unnecessary spam in the forums. Many thanks for your understanding.

#1 2015-07-08 15:54:38

Ironykins
Member
Registered: 2015-06-22
Posts: 9

Session Expiration

Hey people,

I've written a small app to do a large batch upload. It basically just grabs files and fires them at Third Light using the JSON API, throwing them into folders and adding metadata based on how they were stored in our previous image management system.

The problem is that just about every call I make after 16 hours of runtime returns in failure, giving me either an API_ERROR or an ACTION_NOT_PERMITTED.

So I'm wondering if a session automatically expires after 16 hours. If so, is there a way I can tell it to keep my session alive? Or should I just log out and log in again before my time is up?

Offline

#2 2015-07-15 18:09:01

thirdlight
Third Light Staff
Registered: 2013-06-06
Posts: 23

Re: Session Expiration

Hi Ironykins,

If you login with the Core_LoginWithKey() method, you're using an API key to authenticate. That will indeed expire after 16 hours, so you would need to logout/login from time to time to get a new session within the 16 hours.

However, if you use the Core_Login() method using a username and password then you can also set the 'persistent' flag in the options, in which case the session won't expire.

I hope this helps.
Michael

Core_Login
Core.Login(string username, string password[, hash options = NULL]) → hash
string username
The user account's username
string password
The user account's password
hash options
A hash of options, detailed below
Returns hash
Returns a session identifier and some details about the user
Starts an IMS user session. After a successful login, this function returns a session identifier. Depending on the communication method being used to access the API, this identifier can be sent as a cookie with name "IMSSESSID", or sent within the body of the normal request. For further information please see the general usage notes for the API.
The options hash supports the following key:
persistent - allow the session to endure beyond the normal limit
The returned hash will contain keys as follows:
sessionId - a session identifier which should be used in all further communication
userDetails - a hash containing user information
type - the type of entity logged into the system. Normally this will be 1, indicating a conventional user
username - the login username
description - name or description
email - email address

Offline

#3 2015-07-15 19:21:35

Ironykins
Member
Registered: 2015-06-22
Posts: 9

Re: Session Expiration

Cool. This clears things up. We will likely create a service account for our more lengthy jobs with the API. Thanks Michael!

Offline

#4 2015-07-16 16:56:27

dominic
Third Light Staff
Registered: 2013-06-06
Posts: 119

Re: Session Expiration

As of IMS v6.1.8-8, Core.LoginWithKey() also accepts an options hash, supporting 'persistent' as a key within it.

Offline

#5 2015-07-16 17:16:20

Ironykins
Member
Registered: 2015-06-22
Posts: 9

Re: Session Expiration

Thanks man! You're wonderful.

Offline

Board footer