Created
June 8, 2016 11:10
-
-
Save jonaseriksson84/40e0148c0ff22f2d5289815028594fe2 to your computer and use it in GitHub Desktop.
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> | |
<title></title> | |
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.5/angular.js"></script> | |
<script src="https://secure.aadcdn.microsoftonline-p.com/lib/1.0.10/js/adal.min.js"></script> | |
<script src="https://secure.aadcdn.microsoftonline-p.com/lib/1.0.10/js/adal-angular.min.js"></script> | |
</head> | |
<body ng-app="myApp" ng-controller="myController"> | |
{{testMessage}} | |
<button ng-click="login()">Auth ADAL.js</button> | |
<button ng-click="getMessages()">Get messages</button> | |
<script> | |
angular | |
.module('myApp', ['AdalAngular']) | |
.config(function(adalAuthenticationServiceProvider, $httpProvider) { | |
var endpoints = { | |
'https://api.yammer.com': 'https://api.yammer.com' | |
}; | |
adalAuthenticationServiceProvider.init({ | |
// settings made in Azure AD web UI for application | |
instance : 'https://login.microsoftonline.com/', | |
tenant : 'my-tenant-uid', | |
// our applicaiton id | |
clientId : 'my-client-uid', | |
endpoints : endpoints | |
}, $httpProvider ); | |
}) | |
.controller('myController', function ($scope, $http, adalAuthenticationService) { | |
$scope.login = function () { | |
adalAuthenticationService.login(); | |
}; | |
$scope.getMessages = function () { | |
$http({ | |
url: 'https://api.yammer.com/api/v1/messages.json', | |
type: 'GET', | |
}).then(function success(result) { | |
console.log(result); | |
}, function err(error) { | |
console.log(error); | |
}); | |
}; | |
$scope.$on("adal:loginSuccess", function () { | |
console.log('loginSuccess'); | |
$scope.testMessage = "loginSuccess"; | |
}); | |
}); | |
</script> | |
</body> | |
</head> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi @patadata, I only saw this just now - a lot later than you probably neeed it!
The reason I created this gist was because I was in contact with MS Premier Support regarding this. I eventually got the answer that it was not fully working for them (I kept getting a 401 Unauthorized even though all other endpoints worked fine).
I seem to recall getting an update that it had been fixed but I no longer have access to my former employers e-mail address so I couldn't tell you whether it's still an issue.
This is a SO question I posted in conjunction with the above issue, if it's of any help and still relevant:
https://stackoverflow.com/questions/37417764/adal-js-and-yammer-authentication/37562065#37562065