Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE

How to create a mashup in Qlik Sense Enterprise on SaaS

No ratings
cancel
Showing results for 
Search instead for 
Did you mean: 
Sonja_Bauernfeind
Digital Support
Digital Support

How to create a mashup in Qlik Sense Enterprise on SaaS

Last Update:

May 10, 2022 3:01:03 PM

Updated By:

Jamie_Gregory

Created date:

Dec 9, 2020 7:30:04 AM

In Qlik Sense Cloud Services, it is possible to embed charts in a mashup.
However, if the user is not logged in yet when accessing the mashup, it is necessary to write some code to handle the authentication part.

This example is based on the step-by-step provided on the help site: Using Sense APIs > Mashup > Getting started building mashups > Building your first mashup with SaaS editions of Qlik Sense


Environments:

  • Qlik Sense Cloud Services June 2020 and later

 

In this example, it's assumed that helpdesk.html and helpdesk.js are placed in a folder called helpdesk on a webserver. 

You will need to update "yourtenant.eu" to your tenant name and region. 

The WebIntegrationId will also need to be updated, to set up the Web Integration, please follow steps on the help site: Getting set up > Owners and administrators of SaaS deployments > Managing integrations

helpdesk.html

<html>
<head>    
<link rel="stylesheet" href="https://yourtenant.eu.qlikcloud.com/resources/autogenerated/qlik-styles.css">
<script src="https://yourtenant.eu.qlikcloud.com/resources/assets/external/requirejs/require.js"></script>
<script src="helpdesk.js"></script>
<style>
div.flex-container {
    display: flex;
    flex-wrap: wrap;
    margin: 0 45px 45px 0;
}
div.qvobject {
    flex: 1 1 auto;
    height: 300px;
    min-width: 400px;
    margin: 45px 0 0 45px;
}
</style>
</head>
<body>
<div class="flex-container">
	<div id="QV01" class="qvobject"></div>
	<div id="QV02" class="qvobject"></div>
	<div id="QV03" class="qvobject"></div>
	<div id="QV04" class="qvobject"></div>
	<div id="QV05" class="qvobject"></div>
	<div id="QV06" class="qvobject"></div>
</div>
</body>



helpdesk.js

var config = {
    host: 'yourtenant.eu.qlikcloud.com',
    prefix: '/',
    port: 443,
    isSecure: true,
    webIntegrationId: '0pEp-l03lPxDawQxhOSWjKqO_Ckw1WYn'
};

//Redirect to login if user is not logged in
async function login() {
      function isLoggedIn() {
        return fetch("https://"+config.host+"/api/v1/users/me", {
          method: 'GET',
          mode: 'cors',
          credentials: 'include',
          headers: {
            'Content-Type': 'application/json',
            'qlik-web-integration-id': config.webIntegrationId,
          },
        }).then(response => {
          return response.status === 200;
        });
      }
      return isLoggedIn().then(loggedIn => {
        if (!loggedIn) {	  
            window.location.href = "https://"+config.host+"/login?qlik-web-integration-id=" + config.webIntegrationId + "&returnto=" + location.href;
            throw new Error('not logged in');
        }
      });
    }
login().then(() => {
    require.config( {
    baseUrl: ( config.isSecure ? "https://" : "http://" ) + config.host + (config.port ? ":" + config.port : "") + config.prefix + "resources",
    webIntegrationId: config.webIntegrationId
} );			

require( ["js/qlik"], function ( qlik ) {
	qlik.on( "error", function ( error ) {
		$( '#popupText' ).append( error.message + "<br>" );
		$( '#popup' ).fadeIn( 1000 );
	} );
	$( "#closePopup" ).click( function () {
		$( '#popup' ).hide();
	} );
    //open apps -- inserted here --
	var app = qlik.openApp( '8120d03d-3902-4f4e-b0f1-3fee539227ad', config );
	
    //get objects -- inserted here --
	app.visualization.get('DKnjQAk').then(function(vis){
    vis.show("QV01");	
	} );
    
} );});


Lastly, do not forget to update the App ID and object ID (highlighted in blue in the above code)

Now you can access the mashup at: https://yourwebserver/helpdesk/helpdesk.html

Labels (1)
Comments
Anonymous
Not applicable

I was wondering if you tried authenticating with an API Key instead of logging in to the tenant. I assume it should be possible.

Umbi
Contributor II
Contributor II

Hello, 

Would you have any indication on how to proceed that? 

Please let me know, I would love to give it a try...

Actually a WEB Integration ID is already an API Key, is it not?

As a matter of facts I logged a ticket with TechSupport, they did help a lot but they found a bug and they logged a defect ticket: 

QB-7141 - Redirect to authentication in a mashup has stopped working

Damien_Villaret
Support
Support

Hello @Umbi 

Qlik R&D has determined that the issue in QB-7141 was caused by the require(js/qlik) starting loading before the authentication flow has been completed.

This KB has been update to reflect the needed changes to prevent that.
Please re-test with the new code and let us know if that works for you now.

Best regards,

Umbi
Contributor II
Contributor II

Hello @Damien_Villaret 

Many thanks for your post, this sounds as great news.

Unfortunately I have just tried and it does NOT seem to work...Umbi_0-1633530661591.png

To be more precise, what it does is that, if I am not logged in it will pop up the authentication window...

I suppose it should automatically log in should it not?

My understanding is that you are not supposed to log in in order for an end user to display the mashup pages...Is that a correct assumption? I hope it is, otherwise I do not understand how users would beneficial from it...

Try yourself at:

https://funzionamente.it/covid_data/

Thanks, 

Umberto

Damien_Villaret
Support
Support

Hello @Umbi 

There was no change on the server side, the change needs to be done in your mashup code as per this article so that the require(qlik/js) doesn't start loading before the authentication flow is finished.

The expected behavior is:

1. User access the mashup

2. They are redirected to the login page

3. They input their credentials on the login page

4. They are automatically redirected back to the mashup URL.

 

So they still have to log in, but they don't have to open themselves a tab manually in their browser and log in, they will get redirected automatically. At this point Qlik Sense SaaS doesn't support anonymous users.

Best regards,

Umbi
Contributor II
Contributor II

Ah!

OK, then it works, in fact a get redirected to the authentication page and after logging in I successfully see the page...

Unfortunately that is not the kind of functionality I was expecting...

The idea was to have a shareable page anonymously ... 

Shame!

I will need to look for an alternative tool then.

Thanks for your great support as usual and I hope in the future there will be chance to support anonymous users.

Regards!

Umberto

Version history
Last update:
‎2022-05-10 03:01 PM
Updated by: