
dzs06 (dzs06) asked a question.
Created an Okta integration app. Implemented code in .netcore 5.0 to extract the token and authorized the token on the basis of cid and scope.
Created a custom middleware where I am reading the token, decrypting the token and validating the token but I am getting a error:
System.InvalidOperationException: No authenticationScheme was specified, and there was no DefaultChallengeScheme found. The default schemes can be set using either AddAuthentication(string defaultScheme) or AddAuthentication(Action<AuthenticationOptions> configureOptions).
at Microsoft.AspNetCore.Authentication.AuthenticationService.ChallengeAsync(HttpContext context, String scheme, AuthenticationProperties properties)
at Microsoft.AspNetCore.Authorization.Policy.AuthorizationMiddlewareResultHandler.HandleAsync(RequestDelegate next, HttpContext context, AuthorizationPolicy policy, PolicyAuthorizationResult authorizeResult)
at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
at RDS.Web.API.Middlewares.CustomAuthenticationMiddleware.InvokeAsync(HttpContext httpContext) in C:\Users\vipul.aggarwal\Source\Repos\core-backend\RDS.Web.API\Middlewares\CustomAuthenticationMiddleware.cs:line 47
at Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.Invoke(HttpContext httpContext)
at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider)
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
Could anyone help me out with this or anyone can provide any code reference document.

Hello @dzs06 (dzs06) Thank you for reacting out to our Community!
Please see similar questions and resolutions below:
https://support.okta.com/help/s/question/0D51Y000061I3UhSAK/okta-integration-with-aspnet-core-kestrel-and-iis?language=en_US
https://github.com/auth0-samples/auth0-aspnetcore-mvc-samples/issues/29
https://stackoverflow.com/questions/66309761/how-to-solve-this-no-authenticationscheme-was-specified-and-there-was-no-defau
Additionally if you need further assistance we recommend to leverage the Okta Developer forums for this type of questions and take advantage of their expertise.
https://devforum.okta.com/
--
Ask the Experts: Okta Device Access Product Team Now Thru 3/22