title: Error in ADFS Authentication ASP.NET Core + Angular without Oauth
body: <p>when I try to call an API from the frontend I get this error:</p>
  
  <p><a href="https://i.stack.imgur.com/6ts5g.png" rel="nofollow noreferrer">Error Image</a></p>
  
  <p>Error Text:</p>
  
  <p>Access to XMLHttpRequest at '<a href="https://XXX.XXXXX.it/adfs/ls/?wtrealm=https%3A%2F%2Flocalhost%3A44343%2F&amp;wa=wsignin1.0&amp;wreply=https%3A%2F%2Flocalhost%3A44343%2Fsignin-wsfed&amp;wctx=CfDJ8LoBGisiQ49KrBHVuNcYRJKcy1bIbno2NikzQL0qT4dTl4qGoCM3AP2GXKeW9sf0rYN0aYQysbNLx-09dkgcUwkk5dFM9ETH8iFmlkrc-mV6cT7VjFM1zY2kpj1xmw3rFiNDnXr9uaekQd2lGa1Re6KXVcvRKFtYR7kgA_EKH5elgtY-Cu2oeFuRoKuPkXcLcJhYP7Mr4wKQk2AJaTjMDBM" rel="nofollow noreferrer">https://XXX.XXXXX.it/adfs/ls/?wtrealm=https%3A%2F%2Flocalhost%3A44343%2F&amp;wa=wsignin1.0&amp;wreply=https%3A%2F%2Flocalhost%3A44343%2Fsignin-wsfed&amp;wctx=CfDJ8LoBGisiQ49KrBHVuNcYRJKcy1bIbno2NikzQL0qT4dTl4qGoCM3AP2GXKeW9sf0rYN0aYQysbNLx-09dkgcUwkk5dFM9ETH8iFmlkrc-mV6cT7VjFM1zY2kpj1xmw3rFiNDnXr9uaekQd2lGa1Re6KXVcvRKFtYR7kgA_EKH5elgtY-Cu2oeFuRoKuPkXcLcJhYP7Mr4wKQk2AJaTjMDBM</a>' (redirected from '<a href="https://localhost:44343/XXXXX" rel="nofollow noreferrer">https://localhost:44343/XXXXX</a>') from origin '<a href="http://localhost:4200" rel="nofollow noreferrer">http://localhost:4200</a>' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.</p>
  
  <p>This is the implementation of authentication with WsFederation and the enabling of CORS:</p>
  
  <pre><code> public void ConfigureServices(IServiceCollection services)
          {
              services.AddAuthentication(sharedOptions =&gt;
                  {
                      sharedOptions.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme;
                      sharedOptions.DefaultChallengeScheme = WsFederationDefaults.AuthenticationScheme;
                  })
                  .AddWsFederation(options =&gt;
                  {
                      options.Wtrealm = _configuration["ida:Wtrealm"];
                      options.MetadataAddress = _configuration["ida:ADFSMetadata"];
                      options.TokenValidationParameters = new TokenValidationParameters()
                      {
                          ValidateIssuer = false,
  
                      };
  
                  })
                  .AddCookie();
  }
  
  public void Configure(IApplicationBuilder app, IHostingEnvironment env)
          {
              app.UseCors(builder =&gt; builder.AllowAnyHeader().AllowAnyMethod().AllowAnyOrigin());
              app.UseHttpsRedirection();
  
              app.UseAuthentication();
              app.UseAuthorization();
  
              app.ConfigureExceptionHandler();
  
              app.UseMvc();
  }
  </code></pre>
  
  <p>Is it the wrong way?</p>
  
  <p>the only solution is to use OAuth in Angular?</p>
  
  <p>ADFS version is 3.0. </p>
  
  <p>Can you help me??? Thanks</p>