Skip to content

Instantly share code, notes, and snippets.

@prabirshrestha
Last active January 21, 2016 06:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save prabirshrestha/4794da953eb9a93f9466 to your computer and use it in GitHub Desktop.
Save prabirshrestha/4794da953eb9a93f9466 to your computer and use it in GitHub Desktop.
aad single signon in javascript
<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