Got an issue in one specific file where accessing the token happens before setting the token. (I know i should/could rewrite and dig deep down to fix it, but we dont have time...)
Accessing and importing from msal works well in modules :
angular.module('app')
.controller('appCtrl', ['$scope', 'msalAuthenticationService', '$location', '$log', '$http', '$rootScope', function ($scope, msalService, $location, $log, $http, $rootScope) {
$scope.login = function () {
msalService.login();
};
}]);
but in classes it doesn't allow me to import it like this :
import axios from 'axios';
import msalService from '@azure/msal-angularjs';
export class SuperDuperApiClient {
baseUrl = 'xxxxxx/api';
uiUrl = 'xxxxx';
constructor() {
const apiAccessToken = sessionStorage.getItem("api-access-token");
console.log("API TOKEN : ", apiAccessToken);
if (!apiAccessToken) {
msalService.acquireTokenSilent(['xxxxx/Api/user_impersonation']).then(function (token) {
sessionStorage.setItem('api-access-token', token);
})
}
So wanted result is the if check... If the token isn't set, i need to call msal to aquire the token, and set it in sessionstorage.
Error :
Any ideas ?