Angular Okta Integration without login button or link


I am trying to integrate Okta with our angular application which is already in prod using windows authentication. I am replacing Windows authentication with Okta authentication and authorization. I am following the sample example of resource server give here

which works. However the sample application has login link which user has to click to login into the application. I want login to happen when angular application loads. So I put this line this.oktaAuth.loginRedirect() in app.component.ts under ngOnInit event. However it does not work, post application load it redirects to Okta however post Okta login it goes into indefinite loop. If I use login link as provided in the example then it works but not without it. All the examples available on web either use a login link or button which I don’t want. Has someone tried this and if yes then how?

Even I tried this in the sample app provided at the link given above and there too it goes into indefinite loop post Okta login. I don’t see this requirement i.e. login without login link/button out of the world. Is this the limitation if current Okta api?

Any pointers in this regard would be highly appreciated.

Amit Kale

1 Like

Hi Amit,

Were you able to get around this issue? I am facing the same issue of indefinite loop in case I don’t use login link or button.
I don’t want to load my Angular 9 app unless Okta login has been completed successfully. Please let me know if you have any suggestions. Any help much appreciated. Thanks.


You likely want to add logic to your app root so that loginRedirect() is only called if

1 Like