Skip to content

Instantly share code, notes, and snippets.

@Walk4Muscle
Created November 22, 2016 05:48
Show Gist options
  • Save Walk4Muscle/70b11b272131eedfc0360076fcd64b2c to your computer and use it in GitHub Desktop.
Save Walk4Muscle/70b11b272131eedfc0360076fcd64b2c to your computer and use it in GitHub Desktop.
plain javascript for adal for js
<script src="https://secure.aadcdn.microsoftonline-p.com/lib/1.0.11/js/adal.min.js"></script>
<body>
<a href="#" onclick="login();">login</a>
<a href="#" onclick="getToken()">access token</a>
<a href="#" onclick="getUser()">get user</a>
</body>
<script type="text/javascript">
var configOptions = {
tenant: "a75c8de2-xxxx-xxxx-xxxx-4c07fe699a0b", // Optional by default, it sends common
clientId: "90e54701-xxxx-xxxx-xxxx-c2d9b01417f3",
postLogoutRedirectUri: window.location.origin,
}
window.authContext = new AuthenticationContext(configOptions);
var isCallback = authContext.isCallback(window.location.hash);
authContext.handleWindowCallback();
function getToken(){
authContext.acquireToken("https://graph.microsoft.com",function(error, token){
console.log(error);
console.log(token);
})
}
function login(){
authContext.login();
}
function getUser(){
var user = authContext.getCachedUser();
console.log(user);
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment