🔐 Ketivee Universal SSO Integration

📋 Integration Overview

This example demonstrates how to integrate Ketivee Universal SSO into any website or application. The system provides:

  • Auto-detection: Automatically detects if a user has an existing Ketivee account
  • One-click sign-in: Instant authentication for previously connected apps
  • Universal access: Works across all Ketivee subdomains and partner sites
  • Mobile support: Seamless authentication on mobile devices

🚀 Quick Integration (Auto-initialization)

Add this script tag to your HTML for automatic initialization:

<script 
    src="https://api.ketivee.com/sdk/universal/ketivee-sso.js"
    data-ketivee-app-id="YOUR_APP_ID"
    data-ketivee-api-url="https://api.ketivee.com"
    data-ketivee-redirect-url="https://your-app.com/dashboard"></script>

⚙️ Manual Integration (Programmatic)

For more control, initialize the SDK programmatically:

// Initialize Ketivee SSO
const ketiveeSSO = new KetiveeSSO({
    appId: 'YOUR_APP_ID',
    apiUrl: 'https://api.ketivee.com',
    redirectUrl: 'https://your-app.com/dashboard',
    onLogin: (data) => {
        console.log('User logged in:', data.user);
        showUserInfo(data.user);
    },
    onLogout: () => {
        console.log('User logged out');
        hideUserInfo();
    },
    onError: (error) => {
        console.error('SSO Error:', error);
        showStatus('Error: ' + error.message, 'error');
    }
});

// Create sign-in button
const signInBtn = ketiveeSSO.createSignInButton({
    text: 'Sign in with Ketivee',
    className: 'custom-signin-btn',
    style: 'background: #667eea; color: white; padding: 12px 24px; border: none; border-radius: 8px; cursor: pointer;'
});

📱 Mobile App Integration

For mobile applications, use the API endpoints directly:

// Check if user exists
const userStatus = await fetch('https://api.ketivee.com/api/sso/check', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({
        email: '[email protected]',
        appId: 'YOUR_APP_ID',
        redirectUrl: 'your-app://callback'
    })
});

// Authenticate user
const authResult = await fetch('https://api.ketivee.com/api/sso/authenticate', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({
        ssoToken: userStatus.ssoToken,
        password: 'user_password', // if required
        twoFactorCode: '123456' // if 2FA enabled
    })
});

🔗 Universal Authentication Flow

The system automatically handles different authentication scenarios:

  1. New User: Redirects to registration with pre-filled email
  2. Existing User (First Time): Prompts for password and 2FA if enabled
  3. Connected App: One-click instant authentication
  4. Mobile App: Deep link integration for seamless flow