我正在使用msal.js 1.3.2库在angularJS中进行azure AD认证。在重定向后成功登录后,没有得到用户信息对象msal对象,因为它们在重定向后被初始化。以下是我的代码
refApp.config(['$locationProvider', function($locationProvider) {
$locationProvider.html5Mode(false).hashPrefix('');
}]);
refApp.config(['msalAuthenticationServiceProvider', '$httpProvider', function (msalProvider,$httpProvider) {
window.applicationConfig = {
clientID: '<client id>'
};
msalProvider.init(
{
authority: 'https://login.microsoftonline.com/<tenant>.onmicrosoft.com',
validateAuthority : false,
clientID: applicationConfig.clientID,
cacheLocation: 'sessionStorage',
postLogoutRedirectUri: 'https://localhost:8080/logout',
tokenReceivedCallback: function (errorDesc, token, error, tokenType) {
console.log(token);
}
},
$httpProvider
);
}]);
refApp.controller('myController', ['$scope', '$rootScope','$stateParams', '$state', '$location','accountServices', 'msalAuthenticationService', function($scope,$rootScope,$stateParams, $state, $location, accountServices,msalService){
$scope.dispWelcomePage = true;
console.log(msalService); // prints all initialized values after redirect
console.log(msal); // prints all initialized values after redirect
if(!(typeof msalService.userInfo === 'undefined' )){
console.log('userInfo.isAuthenticated is '+msalService.userInfo.isAuthenticated);}//Prints false
$scope.redirectToLoginPage = function(){
console.log("Redirecting to Login page");
msalService.loginRedirect();
}
我按照以下链接中提到的所有步骤进行了操作。https:/github.comAzureADmicrosoft-authentication-library-for-jstreedevlibmsal-angularjs。请谁能给点建议?
请参考 GitHub样本 并确保调用AcquireToken函数。