Skip to main content
Announcements
Global Transformation Awards! Applications are now open. Submit Entry
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Authentication only javaScript

Hi everyone, I have questions about the qlik engine api,

I want consume this API without node.js, this is possible ?

When i try to call with WebSocket, i got this response :

{

     "jsonrpc":"2.0","

     method":"OnAuthenticationInformation",

     "params":

     {

          "loginUri":"https://serverName:443/internal_forms_authentication/?targetId=targetId",

           "mustAuthenticate":true

     }

}

But if i have my cookie X-Qlik-Session set in my browser (after authenticated with the /internal_forms_authentication portal ), the api return expected response.

How Can i simulate this cookie ? or just make a remote authentication(without node js, without certificats, and without windows session).

my code :

var socket = new WebSocket("wss://servername.net/app/%3Ftransient%3D")

var jsondata = (JSON.stringify({

   "handle": -1,
   "method": "GetAuthenticatedUser",
   "params": {},
   "outKey": -1,
   "id": 3
}));
socket.onmessage = function(e){ console.log(e.data); };
socket.onopen = () => socket.send(jsondata);

1 Reply
will_br
Contributor III
Contributor III

I was having the same issue after a Qlik Upgrade [1] and decided to completely change the approach here and it paid off.

I got this working almost instantly using enigma.js (we were using the deprecated qsocks). Enigma.js has some pretty straightforward examples and the one using tickets worked with no struggle at all [2].

 I'd suggest anyone having authentication issues using JS to give that a try

[1]: From Qlik Sense February 2019 to Qlik Sense April 2020.

[2]: https://github.com/qlik-oss/enigma.js/tree/master/examples/authentication/sense-using-ticket