A basic example of using a Node.js backend to integrate with the Qlik Sense Server Mashup API. NOTE: This solution is built to make configuration/distribution simple and provide a foundation for understanding how to create such an environment. It should be considered a building block rather than a production ready solution as it does not cover such things as security. The example uses the Node.js 'http' module to run a simple web server. For more information on the 'http' module please refer to the Node.js documentation - http://nodejs.org/api/http.html
Pre-requisites:
- Node.js
- Qlik Sense Server
Configuration:
-
Node.js
- Open a command/terminal window.
- Browse to the directory of the nodejs-qliksense solution you have just downloaded.
- Install the package by executing 'npm install' in this directory.
- The solution uses the qlik-auth node package which is configured as a dependency and will be installed automatically when you execute the 'npm install' command.
- Using a text editor, open the index.html file and update the hostname and port in the script tags on line 6 to point to your qlik server.
- Using a text editor, open the script.js file in the 'public' folder and update the config, appId and objectId variables to reflect your environment -
- NOTE: Refer to the following link if you are unsure on how to obtain the appId and objectId
- Obtaining app id's and object id's
-
Qlik Sense Server
- Open the QMC (Qlik Management Console) and navigate to the 'Proxies' area.
- Edit the Proxy server settings and ensure to select 'Virtual Proxies' from the options on the right.
- Create a new Virtual proxy with a prefix of your choice (you'll need this prefix when configuring the Node.js site).
- Populate the 'Authentication module redirect URI' with - http://node_server:3000/authenticate
- Port 3000 is configured in the server.js file of the Node.js site and can be changed if desired.
- Add the following 'Additional response header' - Access-Control-Allow-Origin:*
- Navigate to the 'Certificates' area of the QMC.
- Export the certificate, giving it the name of the Node.js machine. By default this is saved in C:\ProgramData\Qlik\Sense\Repository\Exported Certificates.
- Copy the certificate to the root of the Node.js project.
- NOTE: Refer to the following link for help on exporting certificates
- Exporting Certificates
The Authentication Communication Workflow:
- The script.js file in the public folder tries to load the qlik.js mashup API from the configured Qlik Sense Server.
- At this point the 'Authentication module redirect URI' on the virtual proxy is called.
- This is handled by the server.js file of the node solution and currently hardcodes a user called 'sample'.
- The qlik-auth module is then called to send a ticket request with the specified config.
- A ticketId is returned and a session is established.
- No user input is required at any stage of this example workflow.