Infinite loop in the sign in page

The issue is when it is logining in, the sign in page keeps refreshing and calling okta. It looks like the app is in an infinite loop. The attachment shows tjhe issue. Could anyone please solve this issue for me? it is kind of urgent.

My web app is .net core 2 web app.

This part is my configuration in Configuration services:

services.AddAuthentication(sharedOptions =>
                sharedOptions.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme;
                sharedOptions.DefaultChallengeScheme = OpenIdConnectDefaults.AuthenticationScheme;
            .AddCookie(options=> { options.Cookie.SameSite = SameSiteMode.Lax; })
            .AddOpenIdConnect(options =>
                // Configuration pulled from appsettings.json by default:
                options.ClientId = Configuration["okta:ClientId"];
                options.ClientSecret = Configuration["okta:ClientSecret"];
                options.Authority = Configuration["okta:Authority"];
                options.CallbackPath = "/Account/Login";
                //options.ResponseType = "code";
                options.SaveTokens = true;
                options.UseTokenLifetime = false;
                options.GetClaimsFromUserInfoEndpoint = true;
                options.TokenValidationParameters = new TokenValidationParameters
                    NameClaimType = "name"

Login action:

 public IActionResult Login()
            if (!HttpContext.User.Identity.IsAuthenticated)

                return Challenge(OpenIdConnectDefaults.AuthenticationScheme);
            return RedirectToAction("Index", "Home");

Configure method in startup:

            if (env.IsDevelopment())
            app.Use(async (context, next) =>
                if (string.Equals(context.Request.Host.Host.ToString(), "localhost", StringComparison.InvariantCultureIgnoreCase))
                    await next.Invoke();
                    context.Request.Scheme = "https";
                    await next.Invoke();

            //app.UseForwardedHeaders(new ForwardedHeadersOptions
            //    ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto
            app.UseMvc(routes =>
                    name: "default",
                    template: "ItemPerformance/{controller=Account}/{action=Login}/{id?}");
                    name: "default1",
                    template: "{controller=Home}/{action=Index}/{id?}");

If this is urgent - please reach out to they can give your actual SLA, the dev forum does not have an SLA on response times.

@lee.brandt or @nate.barbettini have any thoughts here?

I am not quite sure if I configure OKTA in a wrong way? Probably it is because my code?

I’m a total newb with .NET so I’m not the right person to help.

If you catch the call to the authorize route and the redirect callback, what do they look like from the browser?

The redirect callback may be in error that is causing your code to redirect back to login?

Just trying to help you troubleshoot.

The problem is solved.:joy:

Thanks for the update - what was the issue? Just in case someone else runs into the same problem.

Actually, it is not the problem of OKTA. it is just the url issue. Our app is running in aws docker. So after authentication, the method could not find the correct url to redirect which causes infinite loop. URL is always annoying thing to deal with for web app. :joy::sweat_smile:

1 Like

hello, can someone help me with the looping issue. I integrated Victorops application with okta but users are not able to login as it is always showing a looping screen. I tried this in Okta sandbox but all was fine with it and users could login. One thing to mention here is that in Okta Sandbox, users were created manually and in production they are AD integrated.Can you please suggest…thank you!

Hi Leoliao, could you please post exactly what configuration you used in okta?