Authentication

Learn how to authenticate with Qlik Cloud and Qlik Sense Enterprise environments.

Authentication Overview

The Qlik SDK supports different authentication methods depending on your Qlik environment. Authentication is handled automatically once configured, with support for session management and token refresh.

Qlik Cloud
• OAuth 2.0 with Web Integration ID
• Popup-based authentication flow
• Automatic token refresh
• Session persistence
Qlik Sense Enterprise
• Windows Authentication
• SAML/OIDC integration
• Virtual proxy configuration
• Custom authentication providers

Authentication Methods

Web Integration ID Setup

Configure OAuth 2.0 authentication for Qlik Cloud

1. Create Web Integration in Qlik Cloud

• Navigate to Management Console → Integrations → Web
• Click "Create new" and configure your integration
• Add your domain to allowed origins
• Copy the Web Integration ID

2. Initialize SDK

typescript
const qlik = new Qlik({
  host: 'your-tenant.us.qlikcloud.com',
  webIntegrationId: 'your-web-integration-id'
});

3. Authenticate

typescript
try {
  await qlik.authenticateToQlik();
  console.log('Authentication successful!');
  
  // Now you can make API calls
  const apps = await qlik.getAppList();
} catch (error) {
  console.error('Authentication failed:', error);
}

Authentication Flow

1. SDK opens popup window for Qlik Cloud login
2. User authenticates with their Qlik Cloud credentials
3. Popup closes and SDK receives authorization code
4. SDK exchanges code for access token
5. Token is stored and used for API requests

Session Management

Check Authentication Status

typescript
// Check if user is authenticated
const isAuth = await qlik.isAuthenticated();

if (isAuth) {
  // User is authenticated, proceed
  const apps = await qlik.getAppList();
} else {
  // Redirect to authentication
  await qlik.authenticateToQlik();
}

Logout

typescript
// Logout and clear session
await qlik.logout();

// User is now logged out
// Redirect to login page or show login UI

Error Handling

Authentication Error Patterns

typescript
import Qlik, { QlikAuthError } from 'qlik';

try {
  await qlik.authenticateToQlik();
} catch (error) {
  if (error instanceof QlikAuthError) {
    switch (error.code) {
      case 'POPUP_BLOCKED':
        // Handle popup blocker
        showPopupBlockedMessage();
        break;
        
      case 'AUTHENTICATION_CANCELLED':
        // User cancelled authentication
        showCancelledMessage();
        break;
        
      case 'INVALID_WEB_INTEGRATION_ID':
        // Configuration error
        showConfigErrorMessage();
        break;
        
      default:
        // Generic authentication error
        showGenericAuthError(error.message);
    }
  } else {
    // Network or other error
    console.error('Unexpected error:', error);
  }
}

Common Issues

Popup Blocked: Ensure popup blockers are disabled for your domain
CORS Errors: Add your domain to allowed origins in Web Integration settings
Invalid Web Integration ID: Verify the ID is correct and the integration is active
Session Expired: Implement automatic re-authentication using isAuthenticated()
Network Issues: Check firewall settings and proxy configuration