<?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>topic Mashup with ticket authentication in Integration, Extension &amp; APIs</title>
    <link>https://community.qlik.com/t5/Integration-Extension-APIs/Mashup-with-ticket-authentication/m-p/1572384#M10389</link>
    <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;I am building an mashup application which uses QlikSense tickets for authentication. I have a back end service which runs on different port, is trusted on QS server and I request tickets through it. To authenticate on the front end am using the following steps:&lt;/P&gt;&lt;P&gt;1. Request a ticket.&lt;/P&gt;&lt;P&gt;2. Use ticket to load a png file from Qlik Sense server. This stores a cookie in the browser&lt;/P&gt;&lt;P&gt;3. Load require.js and Qlik Styles from the server.&lt;/P&gt;&lt;P&gt;4. Load qlik object and use it to open the app.&lt;/P&gt;&lt;P&gt;Everything seems to be working perfectly if I use a new ticket every time I reload a page. But what I would like to do is to reuse the cookie (if one exists) instead of recreating it every time. Bu when I try to do that, I am unable to download the png file, and then all the rest requests are failing too, even the QS security cookie exists. Possibly the cross domain (because of different port) requests I do with axios are not using the existing cookie, even when the withCredentials option is set.&lt;/P&gt;&lt;P&gt;My front end app runs on port 8080, backend on 3000 and QlikSens runs on 443. Therefore I am facing cross domain request issues.&lt;/P&gt;&lt;P&gt;Following is a slightly simplified code I am using for this., Could someone give me some hints how to deal with that. Thank you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;import axios from 'axios';

const qlikConfig = {
    host: 'server',
    port: 443,
    secure: true,
    prefix: '',
    appId: ',,,',
    urlParams: {},
};

const getTicket = () =&amp;gt; {
    // Placeholder for getTicket function
    return 'ticket';
};

const connectToQS = async () =&amp;gt; {
    const baseUrl = 'https://server';

    const axiosApp = axios.create({
        withCredentials: true,
    });

    let connected = false;

    // try to connect without ticket. My intention here is, if this succeeds then the cookie exists,
    // just reuse it
    // this is actually failing returning the authentication page
    try {
        const response = await axiosApp.get(`${baseUrl}/img/core/dark_noise_16x16.png`);
        if (response.headers['content-type'] !== 'text/html') {
            connected = true;
        }
    } catch (err) {
        console.log(err);
    }

    // if connected go to loading qliksense and styles
    // if not, request for a ticket and usi it to set a cookie
    // This nbeeds to be run every time, and then everything works
    if (!connected) {
        try {
            const ticket = getTicket();
            await axiosApp.get(`${baseUrl}/img/core/dark_noise_16x16.png?qlikTicket=${ticket}`);
        } catch (err) {
            console.log(err);
        }
    }

    // add require.js to the document
    const requireTag = document.createElement('script');
    requireTag.type = 'text/javascript';
    requireTag.src=`${baseUrl}/assets/external/requirejs/require.js`;
    requireTag.id = 'qliksense-require-tag';
    document.head.appendChild(requireTag);
    requireTag.loaded = new Promise((resolve) =&amp;gt; {
        requireTag.onload = () =&amp;gt; {
            resolve();
        };
    });

    // add qlik style to the document
    const styleTag = document.createElement('link');
    styleTag.type = 'text/css';
    styleTag.rel = 'stylesheet';
    styleTag.href = `${baseUrl}/autogenerated/qlik-styles.css`;
    styleTag.id = 'qliksense-styles-tag';
    document.head.appendChild(styleTag);
    styleTag.loaded = new Promise((resolve) =&amp;gt; {
        styleTag.onload = () =&amp;gt; {
            console.log(`End 2 style ${Date()}`);
            resolve();
        };
    });

    // wait until require.js and
    await Promise.all([styleTag.loaded, requireTag.loaded]);

    window.require.config({
        baseUrl,
        paths: {
            qlik: `${baseUrl}/js/qlik.js`,
        },
        config: {
            text: {
                useXhr() {
                    return true;
                },
            },
        },
    });
    window.require(['js/qlik'], async (qlik) =&amp;gt; {
        const appConfig = {
            host: qlikConfig.host,
            port: qlikConfig.port,
            isSecure: qlikConfig.secure,
            prefix: qlikConfig.prefix,
        };
        const app = qlik.openApp(qlikConfig.appId, appConfig);
    });
};&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 16 Nov 2024 06:01:12 GMT</pubDate>
    <dc:creator>d_pranskus</dc:creator>
    <dc:date>2024-11-16T06:01:12Z</dc:date>
    <item>
      <title>Mashup with ticket authentication</title>
      <link>https://community.qlik.com/t5/Integration-Extension-APIs/Mashup-with-ticket-authentication/m-p/1572384#M10389</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;I am building an mashup application which uses QlikSense tickets for authentication. I have a back end service which runs on different port, is trusted on QS server and I request tickets through it. To authenticate on the front end am using the following steps:&lt;/P&gt;&lt;P&gt;1. Request a ticket.&lt;/P&gt;&lt;P&gt;2. Use ticket to load a png file from Qlik Sense server. This stores a cookie in the browser&lt;/P&gt;&lt;P&gt;3. Load require.js and Qlik Styles from the server.&lt;/P&gt;&lt;P&gt;4. Load qlik object and use it to open the app.&lt;/P&gt;&lt;P&gt;Everything seems to be working perfectly if I use a new ticket every time I reload a page. But what I would like to do is to reuse the cookie (if one exists) instead of recreating it every time. Bu when I try to do that, I am unable to download the png file, and then all the rest requests are failing too, even the QS security cookie exists. Possibly the cross domain (because of different port) requests I do with axios are not using the existing cookie, even when the withCredentials option is set.&lt;/P&gt;&lt;P&gt;My front end app runs on port 8080, backend on 3000 and QlikSens runs on 443. Therefore I am facing cross domain request issues.&lt;/P&gt;&lt;P&gt;Following is a slightly simplified code I am using for this., Could someone give me some hints how to deal with that. Thank you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;import axios from 'axios';

const qlikConfig = {
    host: 'server',
    port: 443,
    secure: true,
    prefix: '',
    appId: ',,,',
    urlParams: {},
};

const getTicket = () =&amp;gt; {
    // Placeholder for getTicket function
    return 'ticket';
};

const connectToQS = async () =&amp;gt; {
    const baseUrl = 'https://server';

    const axiosApp = axios.create({
        withCredentials: true,
    });

    let connected = false;

    // try to connect without ticket. My intention here is, if this succeeds then the cookie exists,
    // just reuse it
    // this is actually failing returning the authentication page
    try {
        const response = await axiosApp.get(`${baseUrl}/img/core/dark_noise_16x16.png`);
        if (response.headers['content-type'] !== 'text/html') {
            connected = true;
        }
    } catch (err) {
        console.log(err);
    }

    // if connected go to loading qliksense and styles
    // if not, request for a ticket and usi it to set a cookie
    // This nbeeds to be run every time, and then everything works
    if (!connected) {
        try {
            const ticket = getTicket();
            await axiosApp.get(`${baseUrl}/img/core/dark_noise_16x16.png?qlikTicket=${ticket}`);
        } catch (err) {
            console.log(err);
        }
    }

    // add require.js to the document
    const requireTag = document.createElement('script');
    requireTag.type = 'text/javascript';
    requireTag.src=`${baseUrl}/assets/external/requirejs/require.js`;
    requireTag.id = 'qliksense-require-tag';
    document.head.appendChild(requireTag);
    requireTag.loaded = new Promise((resolve) =&amp;gt; {
        requireTag.onload = () =&amp;gt; {
            resolve();
        };
    });

    // add qlik style to the document
    const styleTag = document.createElement('link');
    styleTag.type = 'text/css';
    styleTag.rel = 'stylesheet';
    styleTag.href = `${baseUrl}/autogenerated/qlik-styles.css`;
    styleTag.id = 'qliksense-styles-tag';
    document.head.appendChild(styleTag);
    styleTag.loaded = new Promise((resolve) =&amp;gt; {
        styleTag.onload = () =&amp;gt; {
            console.log(`End 2 style ${Date()}`);
            resolve();
        };
    });

    // wait until require.js and
    await Promise.all([styleTag.loaded, requireTag.loaded]);

    window.require.config({
        baseUrl,
        paths: {
            qlik: `${baseUrl}/js/qlik.js`,
        },
        config: {
            text: {
                useXhr() {
                    return true;
                },
            },
        },
    });
    window.require(['js/qlik'], async (qlik) =&amp;gt; {
        const appConfig = {
            host: qlikConfig.host,
            port: qlikConfig.port,
            isSecure: qlikConfig.secure,
            prefix: qlikConfig.prefix,
        };
        const app = qlik.openApp(qlikConfig.appId, appConfig);
    });
};&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 16 Nov 2024 06:01:12 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Integration-Extension-APIs/Mashup-with-ticket-authentication/m-p/1572384#M10389</guid>
      <dc:creator>d_pranskus</dc:creator>
      <dc:date>2024-11-16T06:01:12Z</dc:date>
    </item>
    <item>
      <title>Re: Mashup with ticket authentication</title>
      <link>https://community.qlik.com/t5/Integration-Extension-APIs/Mashup-with-ticket-authentication/m-p/1693044#M12626</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope you managed to solve your issue. I am also running through the same challenges. It would be great if you can share more information on how you did overcome this issue (if you did).&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Apr 2020 16:20:51 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Integration-Extension-APIs/Mashup-with-ticket-authentication/m-p/1693044#M12626</guid>
      <dc:creator>ExperiaCare</dc:creator>
      <dc:date>2020-04-13T16:20:51Z</dc:date>
    </item>
    <item>
      <title>Re: Mashup with ticket authentication</title>
      <link>https://community.qlik.com/t5/Integration-Extension-APIs/Mashup-with-ticket-authentication/m-p/1726908#M13001</link>
      <description>&lt;P&gt;HI&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/6820"&gt;@d_pranskus&lt;/a&gt;&amp;nbsp; and&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/89267"&gt;@ExperiaCare&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;the solution we have here is basically the one described by&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/6820"&gt;@d_pranskus&lt;/a&gt;&amp;nbsp;.&lt;/P&gt;&lt;P&gt;The only difference is that on the mashup we are using JWT authentication and the cookie lasts for the time defined on the proxy -- We do make a new request for the&amp;nbsp;&lt;SPAN&gt;png file&amp;nbsp;&lt;/SPAN&gt;when the page reloads (probably unnecessary?) but we do not when we switch from one qlik app to another (it's a SPA).&lt;/P&gt;&lt;P&gt;--&lt;/P&gt;&lt;P&gt;Using the recent February Qlik version, in a separate tool we got, I only got the ticket authentication working using &lt;SPAN&gt;&lt;A href="https://github.com/qlik-oss/enigma.js/" target="_blank" rel="noopener nofollow noopener noreferrer"&gt;enigma.js&lt;/A&gt;. It's hard to rely on a third-party library that we don't know for how long it will be around but it seems pretty solid.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;They have some pretty straightforward examples and the one using tickets worked almost instantly:&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://github.com/qlik-oss/enigma.js/tree/master/examples/authentication/sense-using-ticket" target="_blank" rel="nofollow noopener noreferrer"&gt;https://github.com/qlik-oss/enigma.js/tree/master/examples/authentication/sense-using-ticket&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Jul 2020 16:01:11 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Integration-Extension-APIs/Mashup-with-ticket-authentication/m-p/1726908#M13001</guid>
      <dc:creator>will_br</dc:creator>
      <dc:date>2020-07-10T16:01:11Z</dc:date>
    </item>
  </channel>
</rss>

