Jump to content

Creating a session via the javascript api

Tim Edelmann

Recommended Posts

Hey everyone, 


as part of our integration process we would like to be able to make api calls "from outside". Since we need to create a session for this, we noticed a difference between python and javascript api. On python side it is possible to create a session object without giving any parameters, if the corresponding environment-variables are set correctly. In javascript this seems to be not allowed! 

export class Session {

     * Construct Session instance with API credentials.
     * @param  {string}  serverUrl -                  ftrack server URL
     * @param  {string}  apiUser -                    ftrack username for API user.
     * @param  {string}  apiKey -                     User API Key
     * @param  {Object}  options  -                   options
     * @param  {Boolean} [options.autoConnectEventHub=false] - Automatically connect to event hub,
     * @param  {Array|null} [options.serverInformationValues=null] - List of server information values to retrieve.
     * @param  {Object}  [options.eventHubOptions={}] - Options to configure event hub with.
     * @constructs Session
        serverUrl, apiUser, apiKey, {
            autoConnectEventHub = false,
            serverInformationValues = null,
            eventHubOptions = {},
            clientToken = null,
        } = {}
    ) {
        if (!serverUrl || !apiUser || !apiKey) {
            throw new Error(
                'Invalid arguments, please construct Session with ' +
                '*serverUrl*, *apiUser* and *apiKey*.'

Why do we have the option to create api-keys without giving it an api-user (on "ftrack-web-ui/system-preferences/API keys") when we cannot use them with the javascript api?

How are we supposed to achieve external api-calls?



thanks in advance 



Link to comment
Share on other sites

Hi Tim,

The API (both JS and Python clients) always requires a valid user,  even when using "Global" API keys.

Where are you using the JavaScript API? As a widget in ftrack,  another web page or from Node?

In a web widget,  we inject the users credentials (assuming the option has been set in the dashboard options).  See the ftrack.widget.load event. If you are using ftrack-web-widget or ftrack-spark-base (see resources and examples) you can call ftrackWidget.getCredentials() at any time to get the users credentials).

In NodeJS, you can replicate the behaviour of the Python API in the following way:

const session = new ftrack.Session(


Link to comment
Share on other sites


This topic is now archived and is closed to further replies.

  • Create New...