I am trying to login a html mashup to Qlik Cloud using JWT auth. The JWT was authenticated and the login was successful. But i am not able to get the visualization of an object. I am getting the following error. How to proceed after this? Any insight on this might be helpful.
var config = {
host: 'yourtenant.eu.qlikcloud.com',
prefix: '/',
port: 443,
isSecure: true,
webIntegrationId: 'F2czdB5yjECRAGLuIi4hiiTEgNjPpW2R',
jwt: 'eyJhbGciOi...VviRm5uOm_0P85_REW_8vgW9O6ueRDg-ErDNNspY7bPZsx2jKgJKyxWgp1dLyq5Hh_HcD7SBh5xbqD8vjkhrhPMAJ-jU98SHcvi33YqCbd8gdHTiDXP3YUuV5ptMKo5ATmcMUb2JhPQMviGLJfCWkJoUhffGOktKSZ36HIiTTfg'
};
//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 => response.status === 200);
}
return isLoggedIn().then((loggedIn) => {
if (!loggedIn) {
return fetch("https://"+config.host+"/login/jwt-session", {
method: 'POST',
mode: 'cors',
credentials: 'include',
headers: {
'Content-Type': 'application/json',
'qlik-web-integration-id': config.webIntegrationId,
'Authorization':'Bearer '+config.jwt
},
}).then((response) => {
if (response.status !== 200) {
throw new Error('failed to login via jwt');
}
});
}
});
}
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( 'fd91cc5b-b59b-4a5f-bfb8-3de888b3882c', config );
//get objects -- inserted here --
app.visualization.get('jCFJJ').then(function(vis){
vis.show("QV01");
});
});
});