Hi,
I am using Okta widget to authenticate user - version 7.1.1.
I have followed the sample from here:
https://developer.okta.com/docs/guides/embedded-siw/main/#create-a-simple-spa
I initialise the OktaSingIn using this kind of method:
function initialiseOktaSignIn(oIssurerUri, oRedirectUri, oClientId){
var oktaConfig = {
issuer: oIssurerUri
, redirectUri: oRedirectUri
, clientId: oClientId
}
// Search for URL Parameters to see if a user is being routed to the application to recover password
var searchParams = new URL(window.location.href).searchParams;
oktaConfig.otp = searchParams.get('otp');
oktaConfig.state = searchParams.get('state');
return new OktaSignIn(oktaConfig);
}
I can login and I can validate the received idToken using /introspect
call.
The login is on page 1:
domain/ctx/app/p1
Then I have my portal pages:
domain/ctx/app/home
And I have logout button on the portal pages. Now I would like to leverage okta widget to logout the user from okta before I redirect him to another process which clears other stuff out. So I created a logout function where I once again initialise the oktaSignIn using the same parameters and the same function which I added before:
function caOktaWidgetLogout(oIssurerUri, oRedirectUri, oClientId) {
const oktaSignIn = initialiseOktaSignIn(oIssurerUri, oRedirectUri, oClientId);
oktaSignIn.authClient.token.getUserInfo().then(function(user) {
console.log("USER INFO: " + JSON.stringify(user));
}, function(error) {
console.log("USER NOT FOUND");
});
oktaSignIn.authClient.session.exists().then(function(exists) {
if (exists) {
console.log("Session EXISTS");
} else {
console.log("Session DOES NOT EXISTS");
}
});
oktaSignIn.authClient.signOut();
//location.reload();
window.event.preventDefault();
//location.reload();
}
Now during the logout function I can see that the oktaSignIn.authClient doesn’t return any user or session so oktaSignIn.authClient.signOut(); doesn’t sign the user out and I still can see that the token is active using the /introspect call.
What am I doing wrongly??? Is it possible to do it the way I want to do it? Or the issue is that I create the oktaSignIn object second time?
Thanks,