我正在开发一个使用Azure广告认证服务的示例应用程序,我使用adal-angular,adal js来执行验证,我能够成功登录,但之后我无法解释收到的令牌,任何人都可以帮助我找到我所缺少的东西?
代码段:
var app = angular.module("myApp", ["ngRoute","AdalAngular"]);
app.config(["$httpProvider","adalAuthenticationServiceProvider",function($httpProvider,adalProvider) {
/*var endpoints ={
"http://localhost:8080/index.jsp/":"https://thirumalaivstgit.onmicrosoft.com/sampangular"
};*/
adalProvider.init(
{
instance: "https://login.microsoftonline.com/",
tenant: "thirumalaivstgit.onmicrosoft.com",
clientId: "f1f7aafc-8901-4755-bb66-a46eae527e33",
redirectUri: 'http://localhost:8080/index.jsp'
},$httpProvider);
}]);
app.controller("getvaluecontroller",["$scope","$http","adalAuthenticationService",function($scope,$http,adalService){
$scope.appname="dfsfgggsgsdg";
$scope.claims = [];
$scope.login=function(){
var loginvalue=adalService.login();
console.log(loginvalue);
}
$scope.userSignedIn=function(err, token)
{
console.log('userSignedIn called');
if (!err) {
console.log("token: " + token);
}
else {
console.error("error: " + err);
}
}
$scope.logout=function(){
adalService.logOut();
}
$scope.afterlogin=function()
{
console.log("afterlogin::" +adalService);
adalService.acquireToken("https://thirumalaivstgit.onmicrosoft.com",function(errorDesc,token,error){
console.log("afterlogin error");
console.log(errorDesc);
console.log(token);
console.log(error);
});
console.log("afterlogin000000");
}
$scope.getvalue=function()
{
console.log("asdfasdfsdfg");
console.log("getvalue::"+adalService.userInfo.profile);
for (var property in adalService.userInfo.profile) {
if (adalService.userInfo.profile.hasOwnProperty(property)) {
$scope.claims.push({
key: property,
value: adalService.userInfo.profile[property],
});
}
}
console.log("getvalue");
}
}])
答案 0 :(得分:0)
您的应用程序不应该解释获得的访问令牌。获得的令牌被设计为对客户端不透明。 Adal-angular implementation的作用是将获得的令牌作为持有者令牌添加到对应用程序自己的后端发出的请求中。令牌的验证发生在后端或web api。
您可以查看此sample了解如何使用adal-angular。