Add Kiges ID sign-in UI to your site. A production integration also needs a server-side authorization-code exchange and an application session.
Browser tools for rendering Kiges ID sign-in UI and starting authorization. Your application completes its own callback and session handling.
Load the browser script to render sign-in UI and start authorization. Your application still needs a callback and server-side session setup.
Can check the Kiges ID session and show a prompt. Browser cookie and privacy settings can limit cross-site session checks.
The current browser SDK includes interface text in nine locales: English, Spanish, Russian, German, French, Chinese, Japanese, Portuguese, and Arabic.
Choose a light, dark, or automatic prompt theme, button style and size, and prompt position using the documented options.
Load the JavaScript file from the Kiges ID host. Check your target browsers and deployment requirements before integrating.
The SDK starts an authorization-code flow and supports PKCE. Your server must securely complete the code exchange.
Register an application in Kiges ID, use its public client ID, and register the exact HTTPS redirect URI your site will use. The authorization server requires an exact redirect URI match. A rendered sign-in button is only the browser step; it does not create an authenticated session in your application.
Keep any client secret on your server. Exchange the authorization code server-side with the same redirect URI and matching PKCE verifier, check failed token and user-info responses, then create your own application session and regenerate its session identifier. Use your framework's CSRF protection for same-origin callback requests. Do not log authorization codes, verifiers, tokens, or credentials.
The SDK creates a random state and PKCE S256 challenge in browser session storage by default, checks state and a ten-minute age on a successful callback, and supplies code, state, and codeVerifier to onSuccess. Keep PKCE enabled for new integrations. This repository does not document how a relying-party server can bind that SDK-generated state to a server-side sign-in transaction; the SDK's browser-side check does not verify a server callback.
For new integrations, set autoPrompt: false and start sign-in from a user action. Automatic session detection depends on cross-site cookies and may not work when browser privacy settings block them.
Use the browser SDK to render a sign-in button. Production sign-in also requires server-side callback handling.
Load the SDK and initialize it with the public client ID for your registered application.
<!-- Load once per page -->
<script src="https://id.kiges.cc/js/kiges-id-sdk.js"></script>
<div id="kiges-login"></div>
<script>
KigesID.init({
clientId: 'YOUR_PUBLIC_CLIENT_ID',
redirectUri: 'https://yoursite.com/callback',
autoPrompt: false
}).then(() => {
KigesID.renderButton('#kiges-login');
}).catch(() => {
// Show a generic initialization error.
});
</script>
The SDK validates the returned state against the browser transaction and provides the code and PKCE verifier to your callback handler. Send these values only to your own server over HTTPS; do not log them.
KigesID.init({
clientId: 'YOUR_CLIENT_ID',
redirectUri: 'https://yoursite.com/callback',
onSuccess: function(data) {
// data.code = authorization code
// Send the short-lived code and verifier to your same-origin server.
// A Laravel page should include its CSRF meta tag in the layout.
const csrfToken = document.querySelector('meta[name="csrf-token"]')?.content;
if (!csrfToken) return;
fetch('/auth/kiges/callback', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-CSRF-TOKEN': csrfToken
},
body: JSON.stringify({
code: data.code,
state: data.state,
code_verifier: data.codeVerifier
})
}).then(response => {
if (!response.ok) throw new Error('Sign-in callback failed');
window.location.assign('/dashboard');
}).catch(() => {
// Show a generic sign-in error; do not expose codes or tokens.
});
},
onError: function() {
// Show a generic authorization error without logging response data.
}
});
The server must exchange the code using the matching redirect URI and PKCE verifier, handle failures, and establish its own session. This repository does not document a complete supported relying-party Laravel callback contract or how to bind the SDK-generated state on the server. Confirm that protocol before implementing this endpoint; the browser-side check is not a server-side callback check. Never put a client secret in browser code.
The browser script and JavaScript API are documented below. Framework-specific examples use the browser script; initialize its page-wide singleton once per application.
The script can initialize from a small set of data attributes. This only configures the SDK prompt; it does not render a sign-in button or create your application's authenticated session. Cross-site status checks can be blocked by browser privacy settings.
<script
src="https://id.kiges.cc/js/kiges-id-sdk.js"
data-kiges-client-id="YOUR_CLIENT_ID"
data-kiges-auto-prompt="true"
data-kiges-theme="dark"
data-kiges-position="bottom-right">
</script>
Use the JavaScript API to configure the SDK and render its sign-in or registration button.
<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: false,
promptPosition: 'bottom-right',
promptDelay: 3000,
theme: 'auto',
onSuccess: (data) => {
// Send code, state, and codeVerifier to your server over HTTPS.
// Never log authorization data.
},
onError: () => { /* show a generic sign-in error */ },
onDismiss: () => { /* optionally update your UI */ }
}).then(() => {
KigesID.renderButton('#my-button', {
theme: 'primary', size: 'large', fullWidth: true, showIcon: true,
mode: 'popup'
});
KigesID.renderSignUpButton('#my-register-button', {
theme: 'outline', mode: 'redirect'
});
}).catch(() => {
// Show a generic initialization error.
});
</script>
All available options for initialization and button rendering.
| Option | Type | Default | Description |
|---|---|---|---|
clientId |
string | - | Required. Your Kiges ID application client ID. |
redirectUri |
string | window.location.origin + window.location.pathname |
Callback URL registered for this client. It must match the authorization request exactly. |
hostedSignInUrl |
string | null |
Optional hosted sign-in URL. When supplied, the SDK adds the OAuth parameters to this URL; otherwise it uses the configured Kiges ID origin. |
hostedSignUpUrl |
string | null |
Hosted sign-up URL used by register() and the sign-up button. Required to start registration. |
origin / customAuthOrigin |
string | https://id.kiges.cc |
Authentication server origin. customAuthOrigin takes precedence when both are set. |
scope |
string | 'openid profile email' |
Space-separated OAuth scopes to request. |
autoPrompt |
boolean | true |
Check central Kiges ID session status and show a prompt. Cross-site cookies may be blocked; consider false for new integrations. |
promptPosition |
string | 'bottom-right' |
Popup position: bottom-right, bottom-left, top-right, top-left, center. |
promptDelay |
number | 1000 |
Delay in ms before showing the auto-prompt. |
theme |
string | 'light' |
UI theme: light, dark, or auto (follows system). |
usePkce |
boolean | true |
Generate a PKCE S256 challenge and retain its verifier in this browser session for the callback. |
responseType |
string | 'code' |
OAuth response type. The documented authorization-code integration uses code. |
locale |
string | null |
Optional locale passed to the hosted authorization page. |
onSuccess |
function | - | Callback after the SDK validates a successful response. Receives { code, state, codeVerifier }; codeVerifier is null if PKCE is disabled. Send these only to your server and never log them. |
onError |
function | - | Callback for authorization errors. The SDK passes an Error object. |
onDismiss |
function | - | Callback when a user dismisses the SDK prompt. |
| Option | Type | Default | Description |
|---|---|---|---|
text |
string | auto | Button text. Auto-translated if not specified. |
theme |
string | 'primary' |
Button style: primary, outline, or dark. |
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' |
Authentication mode: redirect (default) or popup. |
locale |
string | null |
Optional locale passed to hosted authorization. |
authAction |
string | 'login' |
Button action: login or register. |
onClick |
function | null |
Optional click handler that replaces the default sign-in or registration action. |
All public methods available on the KigesID global object.
Initialize the SDK with your configuration. Must be called before other methods.
Programmatically trigger the OAuth login flow.
Programmatically open the hosted account registration flow.
Clears the SDK's in-memory user and prompt. Set endKigesSession: true to navigate through central Kiges ID logout. This does not end your application's own session.
Requests the central Kiges ID session status using cookies. Third-party cookie restrictions can make the check unavailable; inspect the returned result.
Render a styled login button into the given CSS selector.
Render a styled registration button into the given CSS selector.
Manually show the SSO prompt popup.
Hide the SSO prompt popup if visible.
Change the position used for the SDK prompt.
Get the cached user information object.
Returns whether this SDK instance currently holds cached user data. It does not perform a fresh check or inspect your application's session.
Removes the global message listener and prompt, closes an open popup, and clears SDK state. Remove buttons rendered into your own containers separately.
Returns the Kiges ID profile URL for the configured authentication origin.
String containing the browser SDK version.
Framework component examples. Load and initialize the browser SDK once in your application bootstrap before mounting these components.
Load and initialize the browser SDK once at application startup. It exposes a page-wide singleton; a component should remove only its own button when unmounted, not call KigesID.destroy().
import { useEffect, useRef } from 'react';
// Assumes the SDK script has loaded and KigesID.init(...) has completed
// once in the application bootstrap, with onSuccess configured there.
function KigesLoginButton() {
const btnRef = useRef(null);
useEffect(() => {
const button = window.KigesID?.renderButton(btnRef.current, {
theme: 'primary', size: 'large', fullWidth: true
});
return () => button?.remove();
}, []);
return <div ref={btnRef} />;
}
export default KigesLoginButton;
As with React, load and initialize the singleton once outside the component. Do not destroy the global SDK when one component unmounts.
<template>
<div ref="btnContainer" />
</template>
<script setup>
import { ref, onMounted, onUnmounted } from 'vue';
const btnContainer = ref(null);
let button;
onMounted(() => {
// Assumes application bootstrap loaded and initialized KigesID once.
button = window.KigesID?.renderButton(btnContainer.value, {
theme: 'primary', size: 'large', fullWidth: true
});
});
onUnmounted(() => button?.remove());
</script>
Handle onError with a user-facing message that does not expose authorization data. Check that the client ID, requested scopes, and registered redirect URI are correct.
Complete the flow in the same browser session that started it. The SDK stores its transaction in session storage and rejects a missing, mismatched, or older than ten minutes successful response.
Start popup authorization directly from a user action and allow popups for the site. Use redirect mode when popup behavior is unavailable.
checkStatus() depends on the browser sending cookies to Kiges ID. Privacy settings or cookie restrictions can prevent central session detection; provide a sign-in button as the user-controlled fallback.
Check the server response without logging codes, verifiers, secrets, or tokens. Confirm the same redirect URI and PKCE verifier are used. See the API reference for the published endpoint contract.
UI preview only. The sample profile shown in the prompt is fictional; this preview does not authenticate a user or establish an application session. Do not enter real credentials on a demo page.
This button demonstrates the SDK's appearance. The demo client is not a production application.
Preview only; sign-in is disabled.
Click to preview a prompt populated with fictional sample data.