Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run IdentityServer and WebAPI in same project

Currently I have an Identity server that runs perfectly, but I want to add an API on top of it to make some database configuration changes through a web front end. The examples in the docs show how to do this with MVC, but not WebAPI.

The Startup.Configuration method looks like this:

app.UseIdentityServer(new IdentityServerOptions{ ... });

...

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

However, when app.Map gets called, it throws an error because it can't reach the identity server, presumably because it hasn't started yet. How can I get them to properly work together?

like image 780
tVoss42 Avatar asked Apr 21 '16 17:04

tVoss42


1 Answers

This always happens when I post on StackOverflow, I figured it out seconds after I posted! For anyone else having this issue, in the

IdentityServerBearerTokenAuthenticationOptions

set

DelayLoadMetadata = true

and then everything will run smoothly!

like image 115
tVoss42 Avatar answered Sep 28 '22 17:09

tVoss42