Customizing the redirect uri in Spring Boot OAuth2 client application

I have configured the client app for authorization code grant flow. I am using the redirect-uri to http://localhost:8555/login/oauth2/code/okta which is what Spring Security uses to intercept and fetch the access token.
I tried changing the redirect uri to http://localhost:8555/callback and edited the config in application config like below, but there are too many redirects and the token is not retrieved. Where am I going wrong?

spring:
  security:
    oauth2:
      client:
        registration:
          custom:
            clientId: confidential
            clientSecret: confidential
            redirectUri: http://localhost:8555/callback
            scope: openid,email,offline_access
            provider: custom-provider
        provider:
          custom-provider:
            authorizationUri: https://dev-7858070.okta.com/oauth2/default/v1/authorize
            tokenUri: https://dev-7858070.okta.com/oauth2/default/v1/token

I suggest you to check network traffic to see why the looping is happening, this will lead to a more specific question maybe (or even a resolution on your own)

Please change the redirect URI to ‘/authorization-code/callback’ and see if it works. The full redirect URI( http://localhost:8555/authorization-code/callback) should be registered with Okta.