Skip to content

Instantly share code, notes, and snippets.

@slominskir
Created August 15, 2018 17:46
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save slominskir/547730097f9950356df34eb29270c911 to your computer and use it in GitHub Desktop.
Save slominskir/547730097f9950356df34eb29270c911 to your computer and use it in GitHub Desktop.
Example keycloak js client showing check-sso error
<!DOCTYPE html>
<!-- USAGE:
(1) replace myserver.example.com with your keycloak server
(2) replace myrealm with realm
(3) replace myclient with cliend ID
-->
<html>
<head>
<title>Keycloak js client example</title>
</head>
<body>
<script src="https://myserver.example.com/auth/js/keycloak.js"></script>
<script>
var keycloak = Keycloak({
url: 'https://myserver.example.com/auth',
realm: 'myrealm',
clientId: 'myclient'
});
keycloak.init({onLoad: 'check-sso'}).success(function (authenticated) {
if (authenticated) {
console.log('authenticated');
} else {
console.log('not authenticated');
}
}).catch(function () {
alert('failed to initialize');
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment