# Self hosted sign-in widget - showSignInAndRedirect - authorization request not found error

**URL:** <https://devforum.okta.com/t/self-hosted-sign-in-widget-showsigninandredirect-authorization-request-not-found-error/12916>\
**Category:** Questions\
**Created:** [February 12, 2021, 3:05pm UTC](https://devforum.okta.com/t/self-hosted-sign-in-widget-showsigninandredirect-authorization-request-not-found-error/12916 "2021-02-12T15:05:36Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![pramod](https://avatars.discourse-cdn.com/v4/letter/p/71c47a/32.png) [@pramod](https://devforum.okta.com/u/pramod)\
**Post date:** [February 12, 2021, 3:05pm UTC](https://devforum.okta.com/t/self-hosted-sign-in-widget-showsigninandredirect-authorization-request-not-found-error/12916/1 "2021-02-12T15:05:36Z")

</div>

I’m trying to implement self hosted sign-in widget - for web application - using authorization code flow- wrt [GitHub - okta/okta-signin-widget: Okta SignIn widget that renders the new login/auth/recovery flows](https://github.com/okta/okta-signin-widget#web-application)

I’ve used showSignInAndRedirect() option hoping okta would send the response back to the redirectURI.

On the java side, I’ve a controller which is mapped to the requestMapping with the redirectURI - so hoping it would get the control back with the authentication principal. However after the /authorization call where it sends back the code in the URL, I’m getting error [authorization\_request\_not\_found].

Error screenshot  
 ![image](https://global.discourse-cdn.com/oktadev/original/2X/d/d94d9286584c97f565e3595f84963da42dce7015.png)

am I missing anything here? Any help is appreciated.

Code =  
login.html page  
In the head tag, have below

```
<link href="https://global.oktacdn.com/okta-signin-widget/5.3.1/css/okta-sign-in.min.css" type="text/css" rel="stylesheet"/>

```

and then in the script tag

var config = { el : '#sign-in-widget',

```
	 baseUrl: /*[[${oktaBaseUrl}]]*/ 'https://{yourOktaDomain}',
	  //el: '#okta-login-container',
	  clientId: /*[[${oktaClientId}]]*/ '{clientId}',
	  redirectUri: /*[[${redirectUri}]]*/ '{redirectUri}',
	  authParams: {
	    issuer: /*[[${issuerUri}]]*/ '{issuerUri}',
	    pkce: false,
	    responseType: ['code'],
	    scopes: ['openid', 'email', 'profile'],
	   pkce: false
	  }

```

};  
const oktaSignIn = new OktaSignIn(config);  
oktaSignIn.showSignInAndRedirect();  
\</sc ript\>

Controller java code  
@GetMapping("/")  
public ModelAndView login(Authentication principal,HttpServletRequest request,  
HttpServletResponse response) throws MalformedURLException {  
//Check the principal and do something here  
}

---

<div class="post-metadata">

**Author:** ![mraible](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/mraible/32/37_2.png) [@mraible](https://devforum.okta.com/u/mraible)\
**Post date:** [February 12, 2021, 3:08pm UTC](https://devforum.okta.com/t/self-hosted-sign-in-widget-showsigninandredirect-authorization-request-not-found-error/12916/2 "2021-02-12T15:08:32Z")

</div>

I’d suggesting looking at our Spring Java Samples, particularly the [custom-login example](https://github.com/okta/samples-java-spring/tree/master/custom-login). This uses the Sign-In Widget with Spring Boot.

---

<div class="post-metadata">

**Author:** ![pramod](https://avatars.discourse-cdn.com/v4/letter/p/71c47a/32.png) [@pramod](https://devforum.okta.com/u/pramod)\
**Post date:** [February 12, 2021, 3:41pm UTC](https://devforum.okta.com/t/self-hosted-sign-in-widget-showsigninandredirect-authorization-request-not-found-error/12916/3 "2021-02-12T15:41:10Z")

</div>

@mraible - that’s the one I’m referring to. However as with many examples, it’s not suited for prod ready applications and so have customized it a little bit. But it shows the error that I mentioned above.

---

<div class="post-metadata">

**Author:** ![pramod](https://avatars.discourse-cdn.com/v4/letter/p/71c47a/32.png) [@pramod](https://devforum.okta.com/u/pramod)\
**Post date:** [February 12, 2021, 3:52pm UTC](https://devforum.okta.com/t/self-hosted-sign-in-widget-showsigninandredirect-authorization-request-not-found-error/12916/4 "2021-02-12T15:52:38Z")

</div>

Do we’ve any examples for showSignInAndRedirect() usage or signInWithCredentials()

---

<div class="post-metadata">

**Author:** ![bdemers](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/bdemers/32/23_2.png) [@bdemers](https://devforum.okta.com/u/bdemers)\
**Post date:** [February 12, 2021, 4:27pm UTC](https://devforum.okta.com/t/self-hosted-sign-in-widget-showsigninandredirect-authorization-request-not-found-error/12916/5 "2021-02-12T16:27:57Z")

</div>

Hey @pramod!

A couple of things I want to point out. I’d strongly recommend redirecting to Okta instead of hosting the sign-in widget.

This is NOTE Okta specific advice, redirecting to an OAuth IdP is a more secure option:

- Your application (front-end and backend) never handles a user’s passwords
- You can change login policies without affecting your application (no code changes), e.g. enable MFA, or any other new login options.
- The IdP can manage the login page code (and keep it up to date)

Once you customize your Okta domain (and related branding/theming), your users won’t know it’s actually Okta under the covers (example: `https://:login.your-domain.com`):  
[https://developer.okta.com/docs/guides/custom-url-domain/overview/](https://developer.okta.com/docs/guides/custom-url-domain/overview/)

That said, you may have use-cases that are a better fit for managing the login page yourself, in that case, back to your question.

Spring Security’s logging is sparse by default (intentionally, as typical login errors could cause log spam).  
Turn up the logging by setting the following property:

```auto
logging.level.org.springframework.security: DEBUG

```

Let us know what the related exception is and we can point you in the right direction

There may be some info encoded in the URL too (if so include that too).

---

<div class="post-metadata">

**Author:** ![pramod](https://avatars.discourse-cdn.com/v4/letter/p/71c47a/32.png) [@pramod](https://devforum.okta.com/u/pramod)\
**Post date:** [February 12, 2021, 4:42pm UTC](https://devforum.okta.com/t/self-hosted-sign-in-widget-showsigninandredirect-authorization-request-not-found-error/12916/6 "2021-02-12T16:42:41Z")

</div>

Thanks @bdemers for the above points, I’m going to share this in our internal meet to see if we all agree to go for the Okta hosted screen.

I did enable all the logging - but it did not log anything specific -  
logging.level.org.springframework.web.client=DEBUG  
logging.level.web=DEBUG  
logging.level.org.springframework.security=DEBUG  
logging.level.org.springframework.security.oauth2=DEBUG

Here is what I see in the browser console and in the network tab  
 ![image](https://global.discourse-cdn.com/oktadev/original/2X/e/eb097d068415924b54bf15f3c6643b7fd9cba64c.png)

and

 ![image](https://global.discourse-cdn.com/oktadev/original/2X/c/cfdd2ebeebd7b9560382994e2fea3de4e565a3e5.png)

URL call details from the n/w tab  
[globalpay-dev-6161360 - Sign In](https://dev-6161360.okta.com/oauth2/default/v1/authorize?client_id=0oa1ksptlQJRTVndj5d6&nonce=y083lu91aguk09M44XkxFNM9o7IUJSGEnKcYg14sLCs7FkGK9OVHlj4sbCrHy96l&redirect_uri=http://localhost:9090/customLogin/mfaCallBack&response_type=code&sessionToken=20111Bg_I8h8M1VCjr6TW_QMP4xN6KbAvfLrQ4mP-rm5VHPBH2bUINg&state=oXTYfcXhhAXF2oGMCrxxNbV9q2paRthnukZnlOOtaVhgJoWxUXUiZkzS7hVO1Ilb&scope=openid) email profile

 ![image](https://global.discourse-cdn.com/oktadev/original/2X/e/ed42f769de73815d38ffdc7b94617399b017cb68.png)

 ![image](https://global.discourse-cdn.com/oktadev/original/2X/a/a5323446a385b515489010fce7b31808347e340d.png)

---

<div class="post-metadata">

**Author:** ![pramod](https://avatars.discourse-cdn.com/v4/letter/p/71c47a/32.png) [@pramod](https://devforum.okta.com/u/pramod)\
**Post date:** [February 12, 2021, 4:43pm UTC](https://devforum.okta.com/t/self-hosted-sign-in-widget-showsigninandredirect-authorization-request-not-found-error/12916/7 "2021-02-12T16:43:28Z")

</div>

responseHeader for mfaCallBack?code call  
 ![image](https://global.discourse-cdn.com/oktadev/original/2X/a/acd0953b48303b8f589f599179426db7d0469194.png)

responseHeader for login?error call  
 ![image](https://global.discourse-cdn.com/oktadev/original/2X/3/3886929fa8118fbad4dd50d8988f35ee9b3d2994.png)

browser display  
 ![image](https://global.discourse-cdn.com/oktadev/original/2X/3/3bb23748060c99f68a373a41e263218d230733cd.png)

---

<div class="post-metadata">

**Author:** ![pramod](https://avatars.discourse-cdn.com/v4/letter/p/71c47a/32.png) [@pramod](https://devforum.okta.com/u/pramod)\
**Post date:** [February 15, 2021, 4:19pm UTC](https://devforum.okta.com/t/self-hosted-sign-in-widget-showsigninandredirect-authorization-request-not-found-error/12916/8 "2021-02-15T16:19:53Z")

</div>

@bdemers - Did you get a chance to look into this?

Also I forgot to mention earlier that I’ve not downloaded the js & css files on my local but rather referring them from the cdn  
“[https://global.oktacdn.com/okta-signin-widget/5.3.1/js/okta-sign-in.min.js](https://global.oktacdn.com/okta-signin-widget/5.3.1/js/okta-sign-in.min.js)” type=“text/javascript”\>

My understanding is when showSignInAndredirect() is called, it in turn invokes /authorize and /token calls.

> <https://github.com/okta/okta-signin-widget/blob/e8177f1532586849ee8b96384d80c0a6c19eaa3b/src/widget/OktaSignIn.js#L111>

---

<div class="post-metadata">

**Author:** ![GirishAgrawal](https://avatars.discourse-cdn.com/v4/letter/g/c4cdca/32.png) [@GirishAgrawal](https://devforum.okta.com/u/GirishAgrawal)\
**Post date:** [July 25, 2022, 9:50am UTC](https://devforum.okta.com/t/self-hosted-sign-in-widget-showsigninandredirect-authorization-request-not-found-error/12916/9 "2022-07-25T09:50:23Z")

</div>

I am also in similar kind of issue while using self hosted okta sign in widget.  
below is the setup to redirect  
 ![image](https://global.discourse-cdn.com/oktadev/original/2X/a/a0b8c9adfcbdd6e93523ca22ada198d4720c6e58.png)

how and where I need to pass the redirect uri.

---

<div class="post-metadata">

**Author:** ![gouthamk](https://avatars.discourse-cdn.com/v4/letter/g/c67d28/32.png) [@gouthamk](https://devforum.okta.com/u/gouthamk)\
**Post date:** [October 27, 2022, 7:08pm UTC](https://devforum.okta.com/t/self-hosted-sign-in-widget-showsigninandredirect-authorization-request-not-found-error/12916/10 "2022-10-27T19:08:34Z")

</div>

do we have any example with spring mvc, jsp and war getting deployed to tomcat

---

<div class="post-metadata">

**Author:** ![andrea](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/andrea/32/2172_2.png) [@andrea](https://devforum.okta.com/u/andrea)\
**Post date:** [February 12, 2024, 10:16pm UTC](https://devforum.okta.com/t/self-hosted-sign-in-widget-showsigninandredirect-authorization-request-not-found-error/12916/11 "2024-02-12T22:16:15Z")

</div>

Closed on February 12, 2024, 10:16pm UTC


