# Springboot okta hosted login page issue

**URL:** <https://devforum.okta.com/t/springboot-okta-hosted-login-page-issue/34060>\
**Category:** OAuth/OIDC\
**Tags:** spring, java\
**Created:** [July 31, 2025, 11:34pm UTC](https://devforum.okta.com/t/springboot-okta-hosted-login-page-issue/34060 "2025-07-31T23:34:43Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![prashshyam](https://avatars.discourse-cdn.com/v4/letter/p/ec9cab/32.png) [@prashshyam](https://devforum.okta.com/u/prashshyam)\
**Post date:** [July 31, 2025, 11:34pm UTC](https://devforum.okta.com/t/springboot-okta-hosted-login-page-issue/34060/1 "2025-07-31T23:34:43Z")

</div>

Hi,  
I got the okta hosted login page working but now when am trying to sign in by giving the creds of my okta developer account but in the springboot logs am seeing multiple redirects happening and finally shows too\_many\_redirects issue in the browser…my app.properties is as follows

okta.oauth2.redirect-uri=[http://localhost:8080/login/oauth2/code/okta](http://localhost:8080/login/oauth2/code/okta)  
spring.security.oauth2.client.registration.okta.redirect-uri=[http://localhost:8080/login/oauth2/code/okta...did](http://localhost:8080/login/oauth2/code/okta...did) anyone else face this issue…am using okta springboot starter maven dependency 3.0.7…

---

<div class="post-metadata">

**Author:** ![stephval](https://avatars.discourse-cdn.com/v4/letter/s/e9bcb4/32.png) [@stephval](https://devforum.okta.com/u/stephval)\
**Post date:** [August 2, 2025, 9:29pm UTC](https://devforum.okta.com/t/springboot-okta-hosted-login-page-issue/34060/2 "2025-08-02T21:29:53Z")

</div>

Hi!

This is a common issue when setting up an Okta-backed Spring Boot application. The “too many redirects” error almost always indicates a redirect loop. The typical flow for an OAuth 2.0/OIDC application with Okta is:

1. A user tries to access a protected resource in your Spring Boot application.
2. Spring Security detects that the user is not authenticated and redirects them to Okta’s login page.
3. The user signs in successfully on the Okta page.
4. Okta redirects the user’s browser back to your application at the configured `redirect-uri` (e.g., `http://localhost:8080/login/oauth2/code/okta`). This redirect includes an authorization code.
5. Your Spring Boot application receives the authorization code and makes a **back-channel request** to Okta to exchange the code for an access token and an ID token.
6. Your application establishes a session for the user and then redirects them to the resource they were originally trying to access.

A redirect loop occurs when step 5 fails for some reason. The application receives the authorization code but cannot successfully exchange it for tokens. Since the user is still not authenticated from the application’s perspective, the application redirects them back to Okta (step 2), where they are already logged in (due to the Okta session). Okta then redirects them back to your application (step 4), and the cycle repeats.

What you can do is the following:

1. Check your redirect URIs, `application.properties` file must **exactly** match the “Login redirect URIs” configured in your Okta Application Integration.

2. Make sure `http://localhost:8080/login/oauth2/code/okta` is one of the “Login redirect URIs” for your application in the Okta Admin Console. A single typo (e.g., a missing slash or a different port) will cause this issue.

3. The most frequent cause of the token exchange failing is an invalid `issuer`, `client-id`, or `client-secret`. Double-check these values for typos. Copy-pasting them directly is the best way to avoid errors.

- `okta.oauth2.issuer`:This should be the URL of your Okta Authorization Server. For a developer account, it typically looks like `https://dev-xxxxxx.okta.com/oauth2/default`. The `/oauth2/default` part is crucial.

- `okta.oauth2.client-id` and `okta.oauth2.client-secret`: These values must exactly match the ones generated for your application integration in the Okta Admin Console.

Also you can add debug logging level to you application properties, to analyze the logs for any errors related to the token exchange.

Here is a document you an follow: [OAuth 2.0 Java Guide: Secure Your App in 5 Minutes | Okta Developer](https://developer.okta.com/blog/2019/10/30/java-oauth2)

---

<div class="post-metadata">

**Author:** ![prashshyam](https://avatars.discourse-cdn.com/v4/letter/p/ec9cab/32.png) [@prashshyam](https://devforum.okta.com/u/prashshyam)\
**Post date:** [August 3, 2025, 12:50pm UTC](https://devforum.okta.com/t/springboot-okta-hosted-login-page-issue/34060/3 "2025-08-03T12:50:55Z")

</div>

Hi,  
I tried all these but still does not work.Please find the pastebin link…[https://pastebin.com/LeQgcszL...Have](https://pastebin.com/LeQgcszL...Have) verified the URI’s from okta developer account admin console and they match…please suggest

---

<div class="post-metadata">

**Author:** ![prashshyam](https://avatars.discourse-cdn.com/v4/letter/p/ec9cab/32.png) [@prashshyam](https://devforum.okta.com/u/prashshyam)\
**Post date:** [August 4, 2025, 8:38pm UTC](https://devforum.okta.com/t/springboot-okta-hosted-login-page-issue/34060/4 "2025-08-04T20:38:18Z")

</div>

hi,  
Any suggestions please?Been stuck on this for days..

---

<div class="post-metadata">

**Author:** ![stephval](https://avatars.discourse-cdn.com/v4/letter/s/e9bcb4/32.png) [@stephval](https://devforum.okta.com/u/stephval)\
**Post date:** [August 8, 2025, 2:34pm UTC](https://devforum.okta.com/t/springboot-okta-hosted-login-page-issue/34060/5 "2025-08-08T14:34:31Z")

</div>

Have you looked at this previous post with the same issue? [Facing error too many redirects while trying to login with Authorization code flow - #4 by bdemers](https://devforum.okta.com/t/facing-error-too-many-redirects-while-trying-to-login-with-authorization-code-flow/9787/4)

---

<div class="post-metadata">

**Author:** ![prashshyam](https://avatars.discourse-cdn.com/v4/letter/p/ec9cab/32.png) [@prashshyam](https://devforum.okta.com/u/prashshyam)\
**Post date:** [August 13, 2025, 10:34pm UTC](https://devforum.okta.com/t/springboot-okta-hosted-login-page-issue/34060/6 "2025-08-13T22:34:15Z")

</div>

thank you this fixed my issue..

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/oktadev/original/1X/589c4c5f80de422d01f47cee7185a7fb8227835c.png) [@system](https://devforum.okta.com/u/system)\
**Post date:** [August 14, 2025, 10:34pm UTC](https://devforum.okta.com/t/springboot-okta-hosted-login-page-issue/34060/7 "2025-08-14T22:34:16Z")

</div>

Closed on August 14, 2025, 10:34pm UTC

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.
