According to the official docs, in order to access API on a controller withing the same project as the identity provider, I'm supposed to have an equivalent to the following lines, as exemplified at the official site.
public void ConfigureServices(IServiceCollection services)
{
...
services.AddAuthentication(IdentityServerAuthenticationDefaults.AuthenticationScheme)
.AddIdentityServerAuthentication(options =>
{
options.Authority = "https://demo.identityserver.io";
options.ApiName = "api1";
});
}
It doesn't work in my project (I get 401 despite following this answer), so I removed the option.ApiName=...
altogether, only keeping the authority setting. Now it works but it confuses me now.
- Now, where is that api1 supposed to be set?
- Since I'm apparently not setting it, why does the server let me in?
To me, it appears like this.
With ApiName
set.
-"Password!"
-"Hmmm... 'HakunaMatata'..."?
-"Wrong! GFY!"
Without ApiName
set.
-"Password!"
-"Hmmm..." [wall of silence]?
-"Ah, well. You may pass."
-"Hehe, you can GFY..."