Implement the OAuth 2.0 Authorization Code with PKCE Flow

kelvin arbi

anyone know how to implement token validation with netcore 3.1 API?
tried this one https://www.scottbrady91.co…
but returns 'authorization failed’


using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.IdentityModel.Protocols.OpenIdConnect;

namespace PkceClient.AspNetCore3
{
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddControllersWithViews();

services.AddLogging(loggingBuilder =>
{
loggingBuilder.AddConsole();
});

services.AddAuthentication(options =>
{
options.DefaultAuthenticateScheme = “cookie”;
options.DefaultSignInScheme = “cookie”;
options.DefaultChallengeScheme = “oidc”;
})
.AddCookie(“cookie”)
.AddOpenIdConnect(“oidc”, options =>
{


options.Authority = “https://xxx.okta.com”;

options.ClientId = “0oaqkp3xu6sCoZljp4x6”;
options.ResponseType = OpenIdConnectResponseType.Code;
options.ResponseMode = “form_post”;
options.CallbackPath = “/signin-oidc”;

//Enable PKCE(authorization code flow only)
options.UsePkce = true;
});
}

public void Configure(IApplicationBuilder app)
{
app.UseDeveloperExceptionPage();

app.UseStaticFiles();

app.UseRouting();

app.UseAuthentication();
app.UseAuthorization();

app.UseEndpoints(endpoints => endpoints.MapDefaultControllerRoute());
}
}
}