# Not able to connect my App after Redirect from okta log in Page

**URL:** <https://devforum.okta.com/t/not-able-to-connect-my-app-after-redirect-from-okta-log-in-page/22899>\
**Category:** OAuth/OIDC\
**Created:** [December 27, 2022, 3:18pm UTC](https://devforum.okta.com/t/not-able-to-connect-my-app-after-redirect-from-okta-log-in-page/22899 "2022-12-27T15:18:09Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![siddhartha001](https://avatars.discourse-cdn.com/v4/letter/s/d6d6ee/32.png) [@siddhartha001](https://devforum.okta.com/u/siddhartha001)\
**Post date:** [December 27, 2022, 3:18pm UTC](https://devforum.okta.com/t/not-able-to-connect-my-app-after-redirect-from-okta-log-in-page/22899/1 "2022-12-27T15:18:09Z")

</div>

Afte Login to okta page i am getting not found error in redirect url page.  
My code in default.aspx(Login page)

```
    If Not Request.IsAuthenticated Then

        HttpContext.Current.GetOwinContext().Authentication.Challenge(
        New AuthenticationProperties With
        {
        .RedirectUri = "/"
         },
        OpenIdConnectAuthenticationDefaults.AuthenticationType)

    End If

```

I am using OIDC and [asp.net](http://asp.net) web form .

This my Startup.cs file

Private ReadOnly \_clientId As String = ConfigurationManager.AppSettings(“okta:ClientId”)  
Private ReadOnly \_redirectUri As String = ConfigurationManager.AppSettings(“okta:RedirectUri”)  
Private ReadOnly \_authority As String = ConfigurationManager.AppSettings(“okta:OrgUri”)  
Private ReadOnly \_clientSecret As String = ConfigurationManager.AppSettings(“okta:ClientSecret”)

```
    Public Sub Configuration(ByVal app As IAppBuilder)
        ConfigureAuth(app)
    End Sub

    Public Sub ConfigureAuth(ByVal app As IAppBuilder)
        app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie)
        app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType)
        'app.UseCookieAuthentication(
        'New CookieAuthenticationOptions With
        '{.AuthenticationType = "Cookies",
        ' .CookieManager = New Microsoft.Owin.Host.SystemWeb.SystemWebChunkingCookieManager()
        ' })

        app.UseCookieAuthentication(New CookieAuthenticationOptions())
        app.UseOpenIdConnectAuthentication(New OpenIdConnectAuthenticationOptions With {
        .ClientId = _clientId,
        .ClientSecret = _clientSecret,
        .Authority = _authority,
        .RedirectUri = _redirectUri,
        .ResponseType = OpenIdConnectResponseType.CodeIdToken,
        .Scope = OpenIdConnectScope.OpenIdProfile,
        .TokenValidationParameters = New TokenValidationParameters With {
            .NameClaimType = "name"
        },
        .Notifications = New OpenIdConnectAuthenticationNotifications With {
                    .AuthenticationFailed = Function(context)

                                                If context.Exception.Message.Contains("IDX21323") Then
                                                    context.SkipToNextMiddleware()
                                                    Return Task.FromResult(0)
                                                End If
                                                Return Task.FromResult(0)
                                            End Function,
                  .AuthorizationCodeReceived = Async Function(n)
                                                   Dim tokenClient = New TokenClient($"{_authority}/v1/token", _clientId, _clientSecret)
                                                   Dim tokenResponse = Await tokenClient.RequestAuthorizationCodeAsync(n.Code, _redirectUri)

                                                   If tokenResponse.IsError Then
                                                       Throw New Exception(tokenResponse.[Error])
                                                   End If

                                                   Dim userInfoClient = New UserInfoClient($"{_authority}/v1/userinfo")
                                                   Dim userInfoResponse = Await userInfoClient.GetAsync(tokenResponse.AccessToken)
                                                   Dim claims = New List(Of Claim)(userInfoResponse.Claims) From {
                                                 New Claim("id_token", tokenResponse.IdentityToken),
                                                 New Claim("access_token", tokenResponse.AccessToken)
                                             }
                                                   n.AuthenticationTicket.Identity.AddClaims(claims)
                                               End Function,
                  .RedirectToIdentityProvider = Function(n)

                                                    If n.ProtocolMessage.RequestType = OpenIdConnectRequestType.Logout Then
                                                        Dim idTokenClaim = n.OwinContext.Authentication.User.FindFirst("id_token")

                                                        If idTokenClaim IsNot Nothing Then
                                                            n.ProtocolMessage.IdTokenHint = idTokenClaim.Value
                                                        End If
                                                    End If

                                                    Return Task.CompletedTask
                                                End Function
        }
        })

```

 ![Capture2](https://global.discourse-cdn.com/oktadev/original/2X/d/d757fc9c80a4d84743dcc83dfc72a448bb12d9f9.png)

 ![Capture](https://global.discourse-cdn.com/oktadev/original/2X/7/770a75e5c8a48d47ba1436b3e4cd576d67974d80.png)

---

<div class="post-metadata">

**Author:** ![gpadma](https://avatars.discourse-cdn.com/v4/letter/g/858c86/32.png) [@gpadma](https://devforum.okta.com/u/gpadma)\
**Post date:** [December 27, 2022, 8:37pm UTC](https://devforum.okta.com/t/not-able-to-connect-my-app-after-redirect-from-okta-log-in-page/22899/2 "2022-12-27T20:37:25Z")

</div>

Do you see the token api call made to the right end point ? Do you see any failures in okta system log ?

---

<div class="post-metadata">

**Author:** ![siddhartha001](https://avatars.discourse-cdn.com/v4/letter/s/d6d6ee/32.png) [@siddhartha001](https://devforum.okta.com/u/siddhartha001)\
**Post date:** [December 28, 2022, 7:09am UTC](https://devforum.okta.com/t/not-able-to-connect-my-app-after-redirect-from-okta-log-in-page/22899/3 "2022-12-28T07:09:43Z")

</div>

Getting 500 internal server error in network trace of my browser

![Screenshot 2022-12-28 123716](https://global.discourse-cdn.com/oktadev/original/2X/f/f8bfae3cd57d8b9cc4e914b42d698bc084f42409.png)

---

<div class="post-metadata">

**Author:** ![siddhartha001](https://avatars.discourse-cdn.com/v4/letter/s/d6d6ee/32.png) [@siddhartha001](https://devforum.okta.com/u/siddhartha001)\
**Post date:** [December 28, 2022, 7:15am UTC](https://devforum.okta.com/t/not-able-to-connect-my-app-after-redirect-from-okta-log-in-page/22899/4 "2022-12-28T07:15:53Z")

</div>

also getting this issues

 ![Screenshot 2022-12-28 124407](https://global.discourse-cdn.com/oktadev/original/2X/e/e21c12f8ff455a37fde3367cd7d8fc87a3b75dac.png)

---

<div class="post-metadata">

**Author:** ![siddhartha001](https://avatars.discourse-cdn.com/v4/letter/s/d6d6ee/32.png) [@siddhartha001](https://devforum.okta.com/u/siddhartha001)\
**Post date:** [January 3, 2023, 10:36am UTC](https://devforum.okta.com/t/not-able-to-connect-my-app-after-redirect-from-okta-log-in-page/22899/5 "2023-01-03T10:36:42Z")

</div>

Solved the issue by changing the token client

---

<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:** [January 4, 2023, 10:09pm UTC](https://devforum.okta.com/t/not-able-to-connect-my-app-after-redirect-from-okta-log-in-page/22899/6 "2023-01-04T22:09:37Z")

</div>

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