Last active
January 21, 2016 06:57
-
-
Save prabirshrestha/4794da953eb9a93f9466 to your computer and use it in GitHub Desktop.
aad single signon in javascript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
</head> | |
<body> | |
<script src="https://secure.aadcdn.microsoftonline-p.com/lib/1.0.0/js/adal.js"></script> | |
<script> | |
// register app at https://apps.dev.microsoft.com/ | |
var ac = new AuthenticationContext({ | |
clientId: 'clientId', | |
tenant: 'tenantId', | |
cacheLocation: 'localStorage' | |
}); | |
var isCallback = ac.isCallback(window.location.hash); | |
ac.handleWindowCallback(); | |
var user = ac.getCachedUser(); | |
if (!user) { | |
ac.login(); | |
} else { | |
console.log(user); | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment