I upgraded my okta implemetation from v3 to v6 in Angular but now the logout is now working properly. I checked in network tab and found out that the logout url is getting cancelled. (the same logout url is working fine for older okta v3)
I’m using oktaAuth.signOut() function to logout
Hi,
Also after upgrading, did you have a look at our guide that goes through this flow step by step?
from the link that you have provided “import { OktaAuthService } from '@okta/okta-angular” is the older way of using oktaAuth object which was valid till okta-angular v3, in later versions we have to inject OKTA_CONFIG token in constructor to get oktaAuth object as per the documentation provided in @okta/okta-angular npm website.
Direct import of OktaAuthService is not available.
Hi, I’m still stuck in this issue. Please respond if any solution available
Hey there @Shivam
Have you tried comparing your code to the quickstart instructions for sign-in/signout in Angular
Another idea is to use this Quickstart sample and add your Okta config to see if you still see the logout cancelation, which may pinpoint the issue to application setup within the Okta dashboard.
Let us know how that works for you!
I looked into the sample app, I changed code in my application according to sample app.
Previously I was using useFactory for configuring okta but this time I used “OktaAuthModule.forRoot({oktaAuth, onAuthRequired})” which looks a lot cleaner(thanks )
to get the oktaAuth object I’m using this way “oktaAuth = inject(OKTA_AUTH)”
for signout I’m using this “await this.oktaAuth.signOut()”
but even after all of this my logout request is still getting cancelled (rest of the functionalities are working fine so far)
unfortunately I was not able to run the sample app to pinpoint the logout issue because when I put my configuration in it, it requires me to redirect to our main application because in the “issuer” property we put our domain name
Hey @Shivam,
Glad to hear you were able to use forRoot
to streamline setting your configuration! I’m also a fan of the inject function, so using it versus constructor injection is no problem!
Any chance you can share your config with us - it sounds like you have a specialized setup. If you can’t, that’s ok - please share what you can, and we’ll try to work from there.
Hi, I finally found the reason why the logout request was getting cancelled. It was happening because of a @HostListener(‘window:beforeunload’, [‘$event’]) applied in our application which was executing this.oktaAuth.tokenManager.clear() and
this.oktaAuth.closeSession(). Since logout call also reloads the application so this Hostlistener was somehow interrupting the workflow.
Thankyou for the help
Awesome! Glad you figured it out, and thanks for posting the resolution here!
This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.