title: Setting up OpenID Connect for .NET Core Web API
body: <p>I have a simple application which uses Angular as front-end and a .NET Core Web API as back-end services. Now I want to secure my WEB API layer. I though I can use OpenID Connect for that purpose. But all the examples or documentation online uses some identity management systems to like (Keycloak, Okta) but i just want to use my user data from a SQL database. </p>
  
  <p>So something like, I hit the WEB API from Angular to get the token generated(using OpenID?) based on the user details sent. The i can just use the token to Authorize users. I want to use OpenID so that i can use some other identity management systems later if i want to. </p>
  
  <p>my startup class in WEB API</p>
  
  <pre><code>services.AddAuthentication(options =&gt;
              {
                  options.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme;
                  options.DefaultChallengeScheme = OpenIdConnectDefaults.AuthenticationScheme;
  
              })
              .AddCookie()
              .AddOpenIdConnect(o =&gt;
              {
                  o.ClientId = "sa";
                  o.ClientSecret = "sa";
                  o.Authority = "https://localhost:44352";
                  o.GetClaimsFromUserInfoEndpoint = true;
                  o.RequireHttpsMetadata = true;
              });
  </code></pre>
  
  <p>I added a controller with Authorize attribute and added a test method to see what happens when i hit that from Swagger</p>
  
  <p>I see the following error</p>
  
  <pre><code>IOException: IDX20804: Unable to retrieve document from: &amp;#x27;https://localhost:44352/.well-known/openid-configuration&amp;#x27;
  </code></pre>
  
  <p>I am not sure what the error is.</p>
  
  <p>Also I would like to ask if i doing this correct. Can i use the same API (Authority? as in ( o.Authority = "<a href="https://localhost:44352" rel="nofollow noreferrer">https://localhost:44352</a>";)) to authenticate/get token from).  </p>