title: Blazor (Server Side) and Okta
body: <p>I am currently going through this post to integrate okta into a Blazor Server Side App</p>
  
  <p><a href="https://developer.okta.com/blog/2019/10/16/csharp-blazor-authentication" rel="nofollow noreferrer">https://developer.okta.com/blog/2019/10/16/csharp-blazor-authentication</a></p>
  
  <p>I am currently getting “Sorry, there's nothing at this address”. </p>
  
  <p>I was hoping someone could provide a suggestion to my problem.</p>
  
  <p><strong>Or does anyone know of an example to integrate okta into a Blazor Server Side App?</strong> </p>
  
  <p>Please let me know.</p>
  
  <p>Any help would be appreciated. I am totally spinning my wheels.  </p>
  
  <p><strong>Here are my okta General Settings:</strong></p>
  
  <p><a href="https://i.stack.imgur.com/2VToI.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2VToI.png" alt="enter image description here"></a>
  Below is code from my solution (I reviewed the post so many times to make sure it is right. But I guess I could of missed something.)</p>
  
  <p><strong>StartUp ConfigureServices</strong></p>
  
  <pre><code>       services.AddAuthorizationCore();
          services.AddAuthentication(sharedOptions =&gt;
              {
                  sharedOptions.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme;
                  sharedOptions.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
                  sharedOptions.DefaultChallengeScheme = OpenIdConnectDefaults.AuthenticationScheme;
              })
              .AddCookie()
              .AddOpenIdConnect(options =&gt;
              {
                  options.ClientId = Configuration["Okta:ClientId"];
                  options.ClientSecret = Configuration["Okta:ClientSecret"];
                  options.Authority = Configuration["Okta:Issuer"];
                  options.CallbackPath = "/authorization-code/callback";
                  options.ResponseType = "code";
                  options.SaveTokens = true;
                  options.UseTokenLifetime = false;
                  options.GetClaimsFromUserInfoEndpoint = true;
                  options.Scope.Add("openid");
                  options.Scope.Add("profile");
                  options.TokenValidationParameters = new TokenValidationParameters
                  {
                      NameClaimType = "name"
                  };
              });
      }
  </code></pre>
  
  <p><strong>StartUp Configure</strong></p>
  
  <pre><code>    // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
      public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
      {
          if (env.IsDevelopment())
          {
              app.UseDeveloperExceptionPage();
          }
          else
          {
              app.UseExceptionHandler("/Error");
              // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
              app.UseHsts();
          }
  
          app.UseHttpsRedirection();
  
          app.UseStaticFiles();
  
          app.UseRouting();
  
          app.UseAuthentication();
          app.UseAuthorization();
  
          app.UseEndpoints(endpoints =&gt;
          {
              endpoints.MapBlazorHub();
              endpoints.MapFallbackToPage("/_Host");
          });
      }
  </code></pre>
  
  <p><strong>MainLayout.razor</strong></p>
  
  <pre><code>&lt;div class="top-row px-4"&gt;
  
      &lt;AuthorizeView&gt;
          &lt;Authorized&gt;
              &lt;a href="Identity/Account/Manage"&gt;Hello, @context.User.Identity.Name!&lt;/a&gt;
              &lt;a href="Identity/Account/LogOut"&gt;Log out&lt;/a&gt;
          &lt;/Authorized&gt;
          &lt;NotAuthorized&gt;
              &lt;a href="Identity/Account/Register"&gt;Register&lt;/a&gt;
              &lt;a href="Identity/Account/Login"&gt;Log in&lt;/a&gt;
          &lt;/NotAuthorized&gt;
      &lt;/AuthorizeView&gt;
  
      &lt;a href="https://docs.microsoft.com/en-us/aspnet/" target="_blank"&gt;About&lt;/a&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p><strong>App.razor</strong></p>
  
  <pre><code>&lt;CascadingAuthenticationState&gt;
      &lt;Router AppAssembly="@typeof(Program).Assembly"&gt;
          &lt;Found Context="routeData"&gt;
              &lt;AuthorizeRouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" /&gt;
          &lt;/Found&gt;
          &lt;NotFound&gt;
              &lt;LayoutView Layout="@typeof(MainLayout)"&gt;
                  &lt;p&gt;Sorry, there's nothing at this address.&lt;/p&gt;
              &lt;/LayoutView&gt;
          &lt;/NotFound&gt;
      &lt;/Router&gt;
  &lt;/CascadingAuthenticationState&gt; ```
  
  
  
  </code></pre>