MyCode
unknown
html
a year ago
998 B
2
Indexable
Never
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Keycloak OTP Demo</title> <script src="https://your-keycloak-server/auth/js/keycloak.js"></script> </head> <body> <script> const keycloakConfig = { "realm": "your-realm", "url": "https://your-keycloak-server/auth", "clientId": "your-client-id" }; const keycloak = Keycloak(keycloakConfig); keycloak.init({ onLoad: 'login-required' }).success(authenticated => { if (authenticated) { // User is authenticated // Now, you might want to trigger OTP validation or retrieval // Note: Directly obtaining the OTP might not be straightforward due to security measures // You can redirect the user to the standard Keycloak login page window.location.href = keycloak.createLoginUrl(); } }); </script> </body> </html>