I am getting this error "No state in response" after I log out. It comes to the callback url , stays there for sometime and then errors out .BUT After refresh , the state gets appended to the URL and page lands me on the intended login page with a message of successful logout.
Error on logout https://app.something.url?device=desktop#/oops/No%20state%20in%20response
My code below:
User Manager Instance Creation
window.__env = window.__env || {};
var metadataParams = {
issuer: window.__env.ssoUrl,
jwks_uri: window.__env.ssoUrl + '/XX/JWKS', // JSON web key contains encryption information used to validate the token
authorization_endpoint: window.__env.ssoUrl + '/as/XXXXXX', // Authorisation endpoint
token_endpoint: window.__env.ssoUrl + '/as/XXXXX',
userinfo_endpoint: window.__env.ssoUrl + '/idp/XXXXX', // UserInformation endpoint
end_session_endpoint: window.__env.ssoUrl + '/XXX/startXXX.ping' + '?TargetResource=https://' + window.location.hostname + '/somefolder/callback.html' // Logout endpoint
};
window.__env.ssoConfig = {
authority: window.__env.ssoUrl + '/as/XXXXXXX', // AUTH URL on the token during token validation
metadata: metadataParams,
client_id: window.__env.ssoClientId,
redirect_uri: 'https://' + window.location.hostname + '/somefolder/callback.html', // URL where login will redirect
response_type: 'code',
scope: 'XXXXXX',
checkSessionInterval: 10,
silent_redirect_uri:'https://' + window.location.hostname + '/somefolder/callback.html',
automaticSilentRenew: true,
filterProtocolClaims: false,
silentRequestTimeout: 60000,
loadUserInfo: true
};
// create a user manager instance
var userManager = new Oidc.UserManager(window.__env.ssoConfig);
Logout Method:
function logMeOut(params, alternateUrl, override, isLogoutButton) {
var gotoUrl;
var idToken = window.__env.idToken;
params = params || {};
// Clear all storage data
AppStoreData.clearData();
sessionStorage.removeItem('appName-ssoHash');
localStorage.clear();
if (override) {
debug.log('there\'s an override');
gotoUrl = alternateUrl ? alternateUrl : '';
} else {
if (tpUID) {
params.tpUID = tpUID;
}
gotoUrl = setRedirectUrl(defaultReturnUrl, destinationParam, type, params);
debug.log(gotoUrl);
}
sessionStorage.setItem('appname-redirect', encodeURI(gotoUrl));
// if logged in, then... log out with gotoUrl appended
if (idToken && isLogoutButton) {
// Run signout
var logoutSSO = userMgr.signoutRedirect();
logoutSSO.then(function() {
debug.log('logout success');
}).catch(function(err) {
debug.log(err);
debug.log('logout fail');
});
}
//else, go to location
else {
if (gotoUrl) {
window.location = gotoUrl;
}
else {
debug.log('oops: no url to go to');
$state.go('oops');
}
}
}
Callback.html code below:
window.onload = function () {
var redirectUrl = decodeURI(sessionStorage.getItem('appName-redirect'));
if (redirectUrl) {
sessionStorage.setItem('appName-signinRedirect', 'true');
// Redirect back to portal
var params = window.location.search.split('?')[1];
// Remove any states
redirectUrl = redirectUrl.split('#/')[0];
// Redirect back
window.location.href = redirectUrl + '&' + params;
}
}
//Dependencies
"oidc-client": "1.8.2"
"angular": "1.5.8",
"@uirouter/angularjs": "0.3.1"
The Login is successful, it is not having any issues