How to run IdentityServer and WebAPI in one project

I currently have an Identity server that works fine, but I want to add an API on top of it to make some changes to the database configuration via the web interface. The examples in the documents show how to do this with MVC, but not with WebAPI.

The Startup.Configuration method is as follows:

app.UseIdentityServer(new IdentityServerOptions{ ... }); ... app.Map("/api", apiApp => { apiApp.UseIdentityServerBearerTokenAuthentication(new IdentityServerBearerTokenAuthenticationOptions { Authority = "https://localhost:44300", // URL of identity server }); }); 

However, when calling app.Map it gives an error message because it cannot get to the authentication server, presumably because it is not already running. How can I get them to work together properly?

+5
source share
1 answer

This always happens when I post to StackOverflow, I figured it out a few seconds after posting! For everyone who has this problem, in

IdentityServerBearerTokenAuthenticationOptions

set

DelayLoadMetadata = true

and then everything will work smoothly!

+10
source

Source: https://habr.com/ru/post/1247641/


All Articles