Skip to content

Instantly share code, notes, and snippets.

@clarketm
Forked from jerome-labidurie/index.html
Created April 3, 2017 02:04
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 clarketm/03e24d9cf7298646b212a2c317939779 to your computer and use it in GitHub Desktop.
Save clarketm/03e24d9cf7298646b212a2c317939779 to your computer and use it in GitHub Desktop.
Synology SSO server login example
<html>
<head>
<!-- include Synology SSO js -->
<script src="http://ds:5000/webman/sso/synoSSO-1.0.0.js"></script>
</head>
<body>
<script>
/** Display login/logout button.
* Use a html element with id button
* @param logged boolean, are we logged ?
*/
function setButton (logged) {
if (logged) {
document.getElementById('button').innerHTML = '<button onclick="SYNOSSO.logout()">Logout</button>';
} else {
document.getElementById('button').innerHTML = '<button onclick="SYNOSSO.login()">Login</button>';
}
}
/** Callback for SSO.
* Called by init() and login()
* @param reponse the JSON returned by SSO. See Syno SSO Dev Guide.
*/
function authCallback(reponse) {
console.log(JSON.stringify(reponse));
if (reponse.status == 'login') {
console.log('logged');
setButton(true);
}
else {
console.log('not logged ' + reponse.status);
setButton(false);
}
}
SYNOSSO.init({
oauthserver_url: 'http://ds:5000',
app_id: 'a80a2d975796104eb7a7f38b971a8f99',
redirect_uri: 'http://ds/test/relay.html', //no idea what this is :)
callback: authCallback
});
</script>
<h1> Syno SSO test</h1>
<p id='button'></p>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment