<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>article Qlik Sense on Windows: Mashup sample for JWT authentication in Official Support Articles</title>
    <link>https://community.qlik.com/t5/Official-Support-Articles/Qlik-Sense-on-Windows-Mashup-sample-for-JWT-authentication/ta-p/1758514</link>
    <description>&lt;DIV class="lia-message-template-content-zone"&gt;
&lt;P&gt;This is a sample showing how to use JWT authentication in a mashup in Qlik Sense Enterprise for Windows.&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;Environments:&lt;/STRONG&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Qlik Sense Enterprise for Windows November&amp;nbsp;2018 and later&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The way JWT authentication works in Qlik Sense in Windows is that it will validate the JWT token the first time it receives it and creates a session cookie in the browser.&lt;/P&gt;
&lt;P&gt;Once the session cookie is set in the browser, the user is authenticated unless the session expires or he logs out.&lt;/P&gt;
&lt;P&gt;Please note that JWT implementation is different in Qlik Sense for Windows and Qlik Sense on Cloud Services, this sample will not work for Qlik Sense on Cloud Services.&lt;BR /&gt;&lt;BR /&gt;The sample has two files, &lt;FONT face="courier new,courier"&gt;jwtsample.html&lt;/FONT&gt; and&lt;FONT face="courier new,courier"&gt; jwtsample.js&lt;/FONT&gt;, just save the files in the same folder and update the values specific to your environment (highlighted in red below)&lt;BR /&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;jwtsample.html&lt;/FONT&gt;&lt;/P&gt;
&lt;PRE class="ckeditor_codeblock"&gt;&amp;lt;!doctype html&amp;gt;
&amp;lt;html&amp;gt;
&amp;lt;head&amp;gt;
	&amp;lt;meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"&amp;gt;
	&amp;lt;title&amp;gt;Qlik Sense Mashup&amp;lt;/title&amp;gt;
	&amp;lt;meta charset="utf-8"&amp;gt;
	&amp;lt;meta http-equiv="content-type" content="text/html; charset=UTF-8"&amp;gt;
	&amp;lt;meta name="HandheldFriendly" content="True"&amp;gt;
	&amp;lt;meta name="MobileOptimized" content="320"&amp;gt;
	&amp;lt;meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no"&amp;gt;
	&amp;lt;meta name="apple-mobile-web-app-capable" content="yes"&amp;gt;
	&amp;lt;meta name="apple-mobile-web-app-status-bar-style" content="black"&amp;gt;
	&amp;lt;meta http-equiv="cleartype" content="on"&amp;gt;
	&amp;lt;style&amp;gt;
	.flex-container {
		display: flex;
		flex-wrap: wrap;
		margin: 0 45px 45px 0;
	}

	.qvplaceholder, .qvobject {
		flex: 1 1 auto;
		height: 300px;
		min-width: 400px;
		margin: 45px 0 0 45px;
	}
	&amp;lt;/style&amp;gt;	
	&amp;lt;script type="text/javascript"&amp;gt;
		const servernameprefix = "&lt;SPAN&gt;&lt;STRONG&gt;https://qlikserver1.domain.local/jwt&lt;/STRONG&gt;&lt;/SPAN&gt;";
		function login() {
		  function isLoggedIn() {
			return fetch(servernameprefix+"/qrs/about?xrfkey=0000000000000000", {
			  method: 'GET',
			  mode: 'cors',
			  credentials: 'include',
			  headers: {
				'Content-Type': 'application/json',
				'X-Qlik-xrfkey': '0000000000000000',
				'Authorization': 'Bearer &lt;SPAN&gt;&lt;STRONG&gt;eyJhbGciOiJSUzI1NiIsInR5cCI6Ik...vfsfiNrGYeqx0amchtrXbn5gYA&lt;/STRONG&gt;&lt;/SPAN&gt;',
			  },
			}).then(response =&amp;gt; {
			  return response.status === 200;
			});
		  }
		  return isLoggedIn().then(loggedIn =&amp;gt; {
			if (!loggedIn) {
			  alert('You are not logged in');      
			}else{
				//load qlik-styles.css
				var style1 = document.createElement("link");  // create a link DOM node
				style1.type = "text/css";
				style1.rel = "stylesheet";
				style1.href = servernameprefix+"/resources/autogenerated/qlik-styles.css";
				document.head.appendChild(style1);
				
				//load requirejs
				var script = document.createElement("script");  // create a script DOM node
				script.async=false; //this is to ensure that requirejs is loaded before jwtsample.js otherwise it will fail.
				script.defer=false;
				script.src=servernameprefix+"/resources/assets/external/requirejs/require.js";
				document.head.appendChild(script);

				//load the mashup js file
				var script2 = document.createElement("script");  // create a script DOM node
				script2.async=false;
				script2.defer=false;
				script2.src="jwtsample.js";
				document.head.appendChild(script2);
			}
		  });
		}
		login()
	  &amp;lt;/script&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body style="overflow: auto"&amp;gt;
&amp;lt;div class="flex-container"&amp;gt;
	&amp;lt;div id="QV01" class="qvplaceholder"&amp;gt;&amp;lt;/div&amp;gt;
	&amp;lt;div id="QV02" class="qvplaceholder"&amp;gt;&amp;lt;/div&amp;gt;
	&amp;lt;div id="QV03" class="qvplaceholder"&amp;gt;&amp;lt;/div&amp;gt;
&amp;lt;/div&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;&lt;/PRE&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;jwtsample.js&lt;/FONT&gt;&lt;/P&gt;
&lt;PRE class="ckeditor_codeblock"&gt;var config = {
	host: "&lt;SPAN&gt;&lt;STRONG&gt;qlikserver1.domain.local&lt;/STRONG&gt;&lt;/SPAN&gt;",
	prefix: "&lt;SPAN&gt;&lt;STRONG&gt;/jwt/&lt;/STRONG&gt;&lt;/SPAN&gt;",
	port: 443,
	isSecure: true
};
require.config( {
	baseUrl: ( config.isSecure ? "https://" : "http://" ) + config.host + (config.port ? ":" + config.port : "") + config.prefix + "resources"
} );&lt;BR /&gt;
require( ["js/qlik"], function ( qlik ) {
	qlik.on( "error", function ( error ) {
		$( '#popupText' ).append( error.message + "&amp;lt;br&amp;gt;" );
		$( '#popup' ).fadeIn( 1000 );
	} );
	$( "#closePopup" ).click( function () {
		$( '#popup' ).hide();
	} );


	var app = qlik.openApp('&lt;STRONG&gt;&lt;SPAN&gt;106614d5-09ed-4cc3-95bd-e0d4e6b7381d&lt;/SPAN&gt;&lt;/STRONG&gt;', config);

	//get objects -- inserted here --
	app.getObject('QV01','&lt;SPAN&gt;&lt;STRONG&gt;aUsNBCp&lt;/STRONG&gt;&lt;/SPAN&gt;');

} );&lt;/PRE&gt;
&lt;/DIV&gt;</description>
    <pubDate>Tue, 23 Feb 2021 09:15:43 GMT</pubDate>
    <dc:creator>Sonja_Bauernfeind</dc:creator>
    <dc:date>2021-02-23T09:15:43Z</dc:date>
    <item>
      <title>Qlik Sense on Windows: Mashup sample for JWT authentication</title>
      <link>https://community.qlik.com/t5/Official-Support-Articles/Qlik-Sense-on-Windows-Mashup-sample-for-JWT-authentication/ta-p/1758514</link>
      <description>&lt;DIV class="lia-message-template-content-zone"&gt;
&lt;P&gt;This is a sample showing how to use JWT authentication in a mashup in Qlik Sense Enterprise for Windows.&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;Environments:&lt;/STRONG&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Qlik Sense Enterprise for Windows November&amp;nbsp;2018 and later&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The way JWT authentication works in Qlik Sense in Windows is that it will validate the JWT token the first time it receives it and creates a session cookie in the browser.&lt;/P&gt;
&lt;P&gt;Once the session cookie is set in the browser, the user is authenticated unless the session expires or he logs out.&lt;/P&gt;
&lt;P&gt;Please note that JWT implementation is different in Qlik Sense for Windows and Qlik Sense on Cloud Services, this sample will not work for Qlik Sense on Cloud Services.&lt;BR /&gt;&lt;BR /&gt;The sample has two files, &lt;FONT face="courier new,courier"&gt;jwtsample.html&lt;/FONT&gt; and&lt;FONT face="courier new,courier"&gt; jwtsample.js&lt;/FONT&gt;, just save the files in the same folder and update the values specific to your environment (highlighted in red below)&lt;BR /&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;jwtsample.html&lt;/FONT&gt;&lt;/P&gt;
&lt;PRE class="ckeditor_codeblock"&gt;&amp;lt;!doctype html&amp;gt;
&amp;lt;html&amp;gt;
&amp;lt;head&amp;gt;
	&amp;lt;meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"&amp;gt;
	&amp;lt;title&amp;gt;Qlik Sense Mashup&amp;lt;/title&amp;gt;
	&amp;lt;meta charset="utf-8"&amp;gt;
	&amp;lt;meta http-equiv="content-type" content="text/html; charset=UTF-8"&amp;gt;
	&amp;lt;meta name="HandheldFriendly" content="True"&amp;gt;
	&amp;lt;meta name="MobileOptimized" content="320"&amp;gt;
	&amp;lt;meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no"&amp;gt;
	&amp;lt;meta name="apple-mobile-web-app-capable" content="yes"&amp;gt;
	&amp;lt;meta name="apple-mobile-web-app-status-bar-style" content="black"&amp;gt;
	&amp;lt;meta http-equiv="cleartype" content="on"&amp;gt;
	&amp;lt;style&amp;gt;
	.flex-container {
		display: flex;
		flex-wrap: wrap;
		margin: 0 45px 45px 0;
	}

	.qvplaceholder, .qvobject {
		flex: 1 1 auto;
		height: 300px;
		min-width: 400px;
		margin: 45px 0 0 45px;
	}
	&amp;lt;/style&amp;gt;	
	&amp;lt;script type="text/javascript"&amp;gt;
		const servernameprefix = "&lt;SPAN&gt;&lt;STRONG&gt;https://qlikserver1.domain.local/jwt&lt;/STRONG&gt;&lt;/SPAN&gt;";
		function login() {
		  function isLoggedIn() {
			return fetch(servernameprefix+"/qrs/about?xrfkey=0000000000000000", {
			  method: 'GET',
			  mode: 'cors',
			  credentials: 'include',
			  headers: {
				'Content-Type': 'application/json',
				'X-Qlik-xrfkey': '0000000000000000',
				'Authorization': 'Bearer &lt;SPAN&gt;&lt;STRONG&gt;eyJhbGciOiJSUzI1NiIsInR5cCI6Ik...vfsfiNrGYeqx0amchtrXbn5gYA&lt;/STRONG&gt;&lt;/SPAN&gt;',
			  },
			}).then(response =&amp;gt; {
			  return response.status === 200;
			});
		  }
		  return isLoggedIn().then(loggedIn =&amp;gt; {
			if (!loggedIn) {
			  alert('You are not logged in');      
			}else{
				//load qlik-styles.css
				var style1 = document.createElement("link");  // create a link DOM node
				style1.type = "text/css";
				style1.rel = "stylesheet";
				style1.href = servernameprefix+"/resources/autogenerated/qlik-styles.css";
				document.head.appendChild(style1);
				
				//load requirejs
				var script = document.createElement("script");  // create a script DOM node
				script.async=false; //this is to ensure that requirejs is loaded before jwtsample.js otherwise it will fail.
				script.defer=false;
				script.src=servernameprefix+"/resources/assets/external/requirejs/require.js";
				document.head.appendChild(script);

				//load the mashup js file
				var script2 = document.createElement("script");  // create a script DOM node
				script2.async=false;
				script2.defer=false;
				script2.src="jwtsample.js";
				document.head.appendChild(script2);
			}
		  });
		}
		login()
	  &amp;lt;/script&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body style="overflow: auto"&amp;gt;
&amp;lt;div class="flex-container"&amp;gt;
	&amp;lt;div id="QV01" class="qvplaceholder"&amp;gt;&amp;lt;/div&amp;gt;
	&amp;lt;div id="QV02" class="qvplaceholder"&amp;gt;&amp;lt;/div&amp;gt;
	&amp;lt;div id="QV03" class="qvplaceholder"&amp;gt;&amp;lt;/div&amp;gt;
&amp;lt;/div&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;&lt;/PRE&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;jwtsample.js&lt;/FONT&gt;&lt;/P&gt;
&lt;PRE class="ckeditor_codeblock"&gt;var config = {
	host: "&lt;SPAN&gt;&lt;STRONG&gt;qlikserver1.domain.local&lt;/STRONG&gt;&lt;/SPAN&gt;",
	prefix: "&lt;SPAN&gt;&lt;STRONG&gt;/jwt/&lt;/STRONG&gt;&lt;/SPAN&gt;",
	port: 443,
	isSecure: true
};
require.config( {
	baseUrl: ( config.isSecure ? "https://" : "http://" ) + config.host + (config.port ? ":" + config.port : "") + config.prefix + "resources"
} );&lt;BR /&gt;
require( ["js/qlik"], function ( qlik ) {
	qlik.on( "error", function ( error ) {
		$( '#popupText' ).append( error.message + "&amp;lt;br&amp;gt;" );
		$( '#popup' ).fadeIn( 1000 );
	} );
	$( "#closePopup" ).click( function () {
		$( '#popup' ).hide();
	} );


	var app = qlik.openApp('&lt;STRONG&gt;&lt;SPAN&gt;106614d5-09ed-4cc3-95bd-e0d4e6b7381d&lt;/SPAN&gt;&lt;/STRONG&gt;', config);

	//get objects -- inserted here --
	app.getObject('QV01','&lt;SPAN&gt;&lt;STRONG&gt;aUsNBCp&lt;/STRONG&gt;&lt;/SPAN&gt;');

} );&lt;/PRE&gt;
&lt;/DIV&gt;</description>
      <pubDate>Tue, 23 Feb 2021 09:15:43 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Official-Support-Articles/Qlik-Sense-on-Windows-Mashup-sample-for-JWT-authentication/ta-p/1758514</guid>
      <dc:creator>Sonja_Bauernfeind</dc:creator>
      <dc:date>2021-02-23T09:15:43Z</dc:date>
    </item>
  </channel>
</rss>

