In app.js I hava an AuthorizationInterceptorthat checks if user is logged in. When the users token expires it hits the err condition and errors with Frame window timed out (see below) and then goes in to a redirect loop. I want to to do a silent sign in but I guess the iframe is erroring. I cannot see that it ever redirects to the silent-callback.html - it only hits callback.html:
app.factory("AuthorizationInterceptor", ['$q', '$injector', '$rootScope', '$window', 'authService', function ($q, $injector, $rootScope, $window, authService) {
var request = function (requestSuccess) {
var currentTime = Math.floor(Date.now() / 1000);
var deferred = $q.defer();
var oidcManager = window.translation.oidcUserManager;
oidcManager.getUser().then(function (u) {
if (u) {
if (u['expires_at'] < currentTime + 10) {
oidcManager.signinSilent()
.then(function (user) {
requestSuccess.headers['Authorization'] = "Bearer " + user["access_token"];
deferred.resolve(requestSuccess);
}, function (err) {
console.log('getuser error' + err); //this logs the below error.
authService.login();
deferred.resolve(true);
});
} else {
console.log('AuthInterceptor requestSuccess.headers');
requestSuccess.headers['Authorization'] = "Bearer " + u["access_token"];
deferred.resolve(requestSuccess);
}
}
else {
authService.login();
deferred.resolve(true);
}
});
return deferred.promise;
};
Error message logged to console:
getuser errorError: Frame window timed out app.js:92:41
Error: c.paramSerializer is not a function
p@http://localhost:5050/lib/angular/angular.min.js:88:204
n/h<@http://localhost:5050/lib/angular/angular.min.js:86:245
f/<@http://localhost:5050/lib/angular/angular.min.js:118:334
$eval@http://localhost:5050/lib/angular/angular.min.js:132:448
$digest@http://localhost:5050/lib/angular/angular.min.js:129:455
$evalAsync/<@http://localhost:5050/lib/angular/angular.min.js:133:30
e@http://localhost:5050/lib/angular/angular.min.js:43:93
Hf/l.defer/c<@http://localhost:5050/lib/angular/angular.min.js:45:491
This is my setup and function for authService.login()
var config = {
authority: url,
client_id: "js",
redirect_uri: url + "/LocalizationAdmin/callback.html",
response_type: "id_token token",
scope: "openid profile api1",
post_logout_redirect_uri: url + "/LocalizationAdmin/index.html",
silent_redirect_uri: url + "/LocalizationAdmin/silent-callback.html",
automaticSilentRenew: true
};
function login() {
mgr.getUser().then(function (u) {
if (u) {
var currentTime = Math.floor(Date.now() / 1000);
if (u['expires_at'] < currentTime + 10) {
mgr.signinSilent()
.then(function (user) {
var idToken = user.id_token;
var dataIdToken = getDataFromToken(idToken);
}, function (err) {
mgr.signinRedirect();
});
}
}
else {
mgr.signinRedirect();
}
});
Extremely stuck on this one - any help appreciated.