Office365
HTML
<script src="https://appsforoffice.microsoft.com/lib/1.1/hosted/office.js"></script>
<div id='message'></div>
JavaScript
Authenticator = newAuthenticator();
AuthenticationInfo result = await; authenticator.AuthenticateAsync("https://outlook.office365.com");
var authContext;
var authToken; // for use with creating an outlookClient later.
authContext = new O365Auth.Context();
console.log(authContext);
authContext.getIdToken("https://outlook.office365.com/");
.then((function (token) {
authToken = token;
// The auth token also carries additional information. For example:
userName = token.givenName + " " + token.familyName;
}).bind(this), function (reason) {
$('#message').text(reason.message);
});