Skip to content

Instantly share code, notes, and snippets.

@dasniko
Last active September 11, 2020 05:31
Show Gist options
  • Save dasniko/d40cda68560beaf816eb106c06290ca9 to your computer and use it in GitHub Desktop.
Save dasniko/d40cda68560beaf816eb106c06290ca9 to your computer and use it in GitHub Desktop.
<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