You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何从浏览器认证并连接QlikSense Enterprise?基于React构建QlikSense Mashup的适配方案

Great question! Yes, you absolutely can authenticate and connect to QlikSense Enterprise directly from the browser when building your React mashup. The exact approach depends on your QlikSense Enterprise's authentication configuration, so let's break down the most common scenarios and implementations:

1. General Browser-Based Connection (Using Qlik Capability API)

This is the standard method that works with most default QlikSense Enterprise setups:

Prerequisites

  • Your mashup's domain is added to QlikSense Enterprise's allowed origins (configured in the Qlik Management Console under "Virtual Proxies")
  • QlikSense Enterprise has enabled authentication methods compatible with browser flows, such as Windows Authentication (NTLM/Kerberos), Anonymous Access (if permitted), or other browser-friendly schemes

Implementation in React

First, load Qlik's Capability API resources. You can add this to your index.html or dynamically load it in a component:

<script src="https://<your-qlik-enterprise-server>/resources/assets/external/requirejs/require.js"></script>

Then, initialize the Qlik connection in your React component:

import { useEffect } from 'react';

const QlikEnterpriseMashup = () => {
  useEffect(() => {
    // Configure RequireJS to point to Qlik's resources
    window.require.config({
      baseUrl: 'https://<your-qlik-enterprise-server>/resources',
      paths: {
        qlik: 'assets/external/qlik'
      }
    });

    // Load Qlik API and establish connection
    window.require(['qlik'], (qlik) => {
      // Authentication happens automatically here:
      // - For NTLM/Kerberos: Uses the current Windows account logged into the browser
      // - For form-based auth: Redirects to Qlik's login page, sets session cookies post-login
      const qlikApp = qlik.openApp('<your-app-id>', {
        host: '<your-qlik-enterprise-server>',
        prefix: '/',
        port: 443, // Adjust to your Qlik server's port (typically 443 for HTTPS)
        isSecure: true
      });

      // Once connected, you can interact with the app (e.g., render a visualization)
      qlikApp.getObject('qlik-container', '<your-visualization-object-id>');
    });
  }, []);

  return <div id="qlik-container"></div>;
};

export default QlikEnterpriseMashup;

2. JWT-Based Authentication (For Flexible Frontend Integrations)

If your QlikSense Enterprise is configured with JWT authentication, this is a great option for decoupled React apps:

Prerequisites

  • QlikSense Enterprise has JWT Authentication enabled (configured in QMC under "Authentication" with valid public/private keys)
  • Your frontend can retrieve a valid JWT token from your backend authentication service (since frontend shouldn't handle secret key generation)

Implementation in React

import { useEffect, useState } from 'react';

const QlikJwtMashup = () => {
  const [jwtToken, setJwtToken] = useState('');

  // Fetch JWT token from your backend first
  useEffect(() => {
    const fetchQlikJwt = async () => {
      const response = await fetch('/api/your-auth-endpoint');
      const authData = await response.json();
      setJwtToken(authData.qlikJwtToken);
    };
    fetchQlikJwt();
  }, []);

  // Initialize Qlik connection once token is available
  useEffect(() => {
    if (!jwtToken) return;

    window.require.config({
      baseUrl: 'https://<your-qlik-enterprise-server>/resources',
      paths: { qlik: 'assets/external/qlik' }
    });

    window.require(['qlik'], (qlik) => {
      const qlikApp = qlik.openApp('<your-app-id>', {
        host: '<your-qlik-enterprise-server>',
        prefix: '/',
        port: 443,
        isSecure: true,
        jwt: jwtToken // Pass the JWT token for authentication
      });

      // Interact with the app as needed
      qlikApp.getObject('jwt-qlik-container', '<your-visualization-object-id>');
    });
  }, [jwtToken]);

  return <div id="jwt-qlik-container"></div>;
};

export default QlikJwtMashup;

Key Notes & Troubleshooting

  • CORS Issues: Always ensure your mashup's domain is added to the Qlik virtual proxy's allowed origins—otherwise, the browser's CORS policy will block requests.
  • Virtual Proxy Customization: For non-default auth flows (like JWT), you'll likely need to create a custom virtual proxy in QMC to handle the authentication scheme and CORS settings.
  • Form-Based Auth: If your QlikSense uses form-based LDAP or SAML, the browser will automatically redirect to Qlik's login page; after successful login, session cookies will let your mashup connect seamlessly.

内容的提问来源于stack exchange,提问作者gangata arun

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.30 10:37:28