Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<html>
<head>
<script src="keycloak.js"></script>
</head>
<body>
<!-- your usual content goes here... -->
<script>
var keycloak = new Keycloak({
url: 'http://localhost:8080/auth',
realm: 'demo',
clientId: 'bookBox'
});
keycloak.init().then(function(authenticated) {
alert(authenticated ? 'authenticated' : 'not authenticated');
}).catch(function (err) {
alert('failed to initialize: ' + err);
});
</script>
</body>
</html>
<html>
<head>
<script src="keycloak.js"></script>
<script>
var keycloak = new Keycloak({
url: 'http://localhost:8080/auth',
realm: 'demo',
clientId: 'bookBox'
});
function initKc() {
keycloak.init().then(function(authenticated) {
alert(authenticated ? 'authenticated' : 'not authenticated');
}).catch(function (err) {
alert('failed to initialize: ' + err);
});
}
</script>
</head>
<body onload="initKc()>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment