Kiges ID SDK

Enterprise-grade Single Sign-On integration for any website. One script, full control, beautiful UI.

Everything You Need

A complete SSO toolkit designed for developers who demand both simplicity and power.

⚡

One-Line Integration

Add a single script tag to enable SSO. No build tools, no npm install, no server changes.

🔍

Auto-Detect Users

Automatically checks if visitors are logged into Kiges ID and shows a personalized prompt.

🌐

20+ Languages

Buttons and prompts auto-translate based on browser language. Override with a single option.

🎨

Themes & Customization

Light, dark, and auto modes. Three button styles. Five popup positions. Full CSS control.

📦

Zero Dependencies

Pure vanilla JavaScript. Under 18 KB gzipped. Works in all modern browsers.

🔒

Secure OAuth 2.0

Industry-standard authorization code flow with PKCE support and CSRF protection.

Get Started in 3 Steps

From zero to working SSO button in under 2 minutes.

1

Add the SDK Script

Include the SDK in your HTML. Use data attributes for zero-config setup.

HTML
<!-- Add before </body> -->
<script
    src="https://id.kiges.cc/js/kiges-id-sdk.js"
    data-kiges-client-id="YOUR_CLIENT_ID"
    data-kiges-redirect-uri="https://yoursite.com/callback"
    data-kiges-auto-prompt="true">
</script>
2

Handle the Callback

Listen for the authorization code on your callback page.

JavaScript
KigesID.init({
    clientId: 'YOUR_CLIENT_ID',
    redirectUri: 'https://yoursite.com/callback',
    onSuccess: function(data) {
        // data.code = authorization code
        // Send to your server to exchange for token
        fetch('/auth/kiges/callback', {
            method: 'POST',
            headers: { 'Content-Type': 'application/json' },
            body: JSON.stringify({ code: data.code })
        });
    },
    onError: function(error) {
        console.error('Auth failed:', error);
    }
});
3

Exchange Code on Server

Exchange the authorization code for an access token on your backend.

PHP / Laravel
// routes/web.php
Route::post('/auth/kiges/callback', function (Request $request) {
    $response = Http::asForm()->post('https://id.kiges.cc/oauth/token', [
        'grant_type'    => 'authorization_code',
        'client_id'     => config('services.kiges.client_id'),
        'client_secret' => config('services.kiges.client_secret'),
        'redirect_uri'  => config('services.kiges.redirect'),
        'code'          => $request->code,
    ]);

    $user = Http::withToken($response['access_token'])
        ->get('https://id.kiges.cc/api/user');

    // Create or update user in your database
    Auth::login(User::updateOrCreate(
        ['kiges_id' => $user['id']],
        ['name' => $user['name'], 'email' => $user['email']]
    ));

    return redirect('/dashboard');
});

Integration Methods

Choose the approach that fits your project. All methods are fully supported.

Zero-Config with Data Attributes

The simplest approach. Just add data attributes to the script tag and the SDK handles everything automatically.

HTML
<script
    src="https://id.kiges.cc/js/kiges-id-sdk.js"
    data-kiges-client-id="YOUR_CLIENT_ID"
    data-kiges-redirect-uri="https://yoursite.com/callback"
    data-kiges-auto-prompt="true"
    data-kiges-theme="dark"
    data-kiges-position="bottom-right"
    data-kiges-button="#login-btn">
</script>

<!-- Button will render here -->
<div id="login-btn"></div>

Full Control with JavaScript API

For maximum customization and programmatic control over every aspect of the SSO flow.

JavaScript
<script src="https://id.kiges.cc/js/kiges-id-sdk.js"></script>
<script>
    // Initialize with full options
    KigesID.init({
        clientId: 'YOUR_CLIENT_ID',
        redirectUri: 'https://yoursite.com/callback',
        hostedSignInUrl: 'YOUR_HOSTED_SIGN_IN_URL',
        hostedSignUpUrl: 'YOUR_HOSTED_SIGN_UP_URL',
        scope: 'openid profile email',
        autoPrompt: true,
        promptPosition: 'bottom-right',
        promptDelay: 3000,
        theme: 'auto',
        onSuccess: (data) => console.log('Success:', data),
        onError: (err) => console.error('Error:', err),
        onDismiss: () => console.log('Dismissed')
    });

    // Render a styled button
    KigesID.renderButton('#my-button', {
        theme: 'primary',
        size: 'large',
        fullWidth: true,
        showIcon: true,
        mode: 'popup'
    });

    KigesID.renderSignUpButton('#my-register-button', {
        theme: 'outline',
        mode: 'redirect'
    });
</script>

NPM Package (Coming Soon)

Install via npm for bundler-friendly integration with React, Vue, Angular, and other frameworks.

Terminal
# Coming soon
npm install @kiges/id-sdk

# React
import { KigesIDButton } from '@kiges/id-sdk/react';

# Vue
import { KigesIDButton } from '@kiges/id-sdk/vue';

Configuration Reference

All available options for initialization and button rendering.

Initialization Options

Option Type Default Description
clientId string - Required. Your Kiges ID application client ID.
redirectUri string window.location.origin + '/callback' OAuth callback URL registered in your app.
scope string 'openid profile email' Space-separated OAuth scopes to request.
autoPrompt boolean true Show a popup prompt for logged-in Kiges users.
promptPosition string 'bottom-right' Popup position: bottom-right, bottom-left, top-right, top-left, center.
promptDelay number 2000 Delay in ms before showing the auto-prompt.
theme string 'auto' UI theme: light, dark, or auto (follows system).
onSuccess function - Callback on successful authorization. Receives { code }.
onError function - Callback on error. Receives error object.
onDismiss function - Callback when user dismisses the prompt.

Button Options

Option Type Default Description
text string auto Button text. Auto-translated if not specified.
theme string 'primary' Button style: primary, outline, or minimal.
size string 'medium' Button size: small, medium, or large.
fullWidth boolean false Stretch button to fill container width.
showIcon boolean true Show the Kiges ID logo icon on the button.
mode string 'redirect' Login mode: redirect (full page) or popup (new window).

API Reference

All public methods available on the KigesID global object.

KigesID.init(options)

Initialize the SDK with your configuration. Must be called before other methods.

KigesID.login()

Programmatically trigger the OAuth login flow.

KigesID.register()

Programmatically open the hosted account registration flow.

KigesID.logout(options)

Clear local auth state. Set endKigesSession: true to end the central Kiges ID session.

KigesID.checkStatus()

Check if the current user is logged into Kiges ID.

KigesID.renderButton(sel, opts)

Render a styled login button into the given CSS selector.

KigesID.renderSignUpButton(sel, opts)

Render a styled registration button into the given CSS selector.

KigesID.showPrompt()

Manually show the SSO prompt popup.

KigesID.hidePrompt()

Hide the SSO prompt popup if visible.

KigesID.getUser()

Get the cached user information object.

KigesID.isLoggedIn()

Returns true if the user is currently authenticated.

KigesID.destroy()

Clean up all SDK elements and event listeners.

Framework Examples

Ready-to-use integration examples for popular frameworks.

React

React Component
import { useEffect, useRef } from 'react';

function KigesLoginButton({ clientId, onSuccess }) {
    const btnRef = useRef(null);

    useEffect(() => {
        // Load SDK
        const script = document.createElement('script');
        script.src = 'https://id.kiges.cc/js/kiges-id-sdk.js';
        script.onload = () => {
            window.KigesID.init({
                clientId,
                onSuccess,
                onError: (err) => console.error(err)
            });
            window.KigesID.renderButton(btnRef.current, {
                theme: 'primary',
                size: 'large',
                fullWidth: true
            });
        };
        document.body.appendChild(script);
        return () => window.KigesID?.destroy();
    }, [clientId]);

    return <div ref={btnRef} />;
}

export default KigesLoginButton;

Vue 3

Vue Composition API
<template>
  <div ref="btnContainer" />
</template>

<script setup>
import { ref, onMounted, onUnmounted } from 'vue';

const props = defineProps({ clientId: String });
const emit = defineEmits(['success', 'error']);
const btnContainer = ref(null);

onMounted(() => {
    const script = document.createElement('script');
    script.src = 'https://id.kiges.cc/js/kiges-id-sdk.js';
    script.onload = () => {
        window.KigesID.init({
            clientId: props.clientId,
            onSuccess: (data) => emit('success', data),
            onError: (err) => emit('error', err)
        });
        window.KigesID.renderButton(btnContainer.value, {
            theme: 'primary', size: 'large', fullWidth: true
        });
    };
    document.body.appendChild(script);
});

onUnmounted(() => window.KigesID?.destroy());
</script>

Try It Live

Interact with a live instance of the SDK. Click the buttons below to test different popup positions.

Login Button Preview

This is a live-rendered Kiges ID button.

Popup Position Test

Click a position to see the SSO prompt appear there.