Unable to obtain configuration from well-known/openid-configuration

后端 未结 7 1729
感情败类
感情败类 2020-12-17 21:22

I am using ASP.NET 5, In my solution I have Web API, Identity Server and Angular 2 project and I am authenticating Angular 2 client by using Identity Server, Angular 2 clien

相关标签:
7条回答
  • 2020-12-17 21:49

    I used something like this, and it resolved my issue.

    services.AddAuthentication(o => {
                o.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
                o.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
            })            
            .AddCookie(cfg => cfg.SlidingExpiration = true)
            .AddJwtBearer(cfg =>
            {
                cfg.Audience = "http://localhost:4200/";
                cfg.Authority = "http://localhost:5000/";
                cfg.RequireHttpsMetadata = false;
                cfg.SaveToken = true;
                cfg.TokenValidationParameters = tokenValidationParameters;
                cfg.Configuration = new OpenIdConnectConfiguration();  <-- Most IMP Part
            });
    
    0 讨论(0)
  • 2020-12-17 21:52

    The reason for this error was proxy and was able to resolve it by implementing the code below:

    options.BackchannelHttpHandler = new HttpClientHandler()
                {
                    ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator,
                    Proxy = new WebProxy(Configuration["System:Proxy"])
                };
    

    If you are getting "unable to retrieve document from: '[pii is hidden]'" you need to add below to ConfigureServices:

        public void ConfigureServices(IServiceCollection services)
                {
    ......
    IdentityModelEventSource.ShowPII = true;
        }
    

    I hope this help.

    0 讨论(0)
  • 2020-12-17 22:00

    If identityserver and the access token validation middleware are hosted in the same application there is a race condition at startup.

    The validation middleware tries to load the discovery document, which is not yet available.

    In these scenarios, set the DelayLoadMetadata flag on the validation middleware to true.

    If you disable the discovery endpoint altogether, you need to configure the issuer and key material on the validation options.

    0 讨论(0)
  • 2020-12-17 22:04

    Check your appsettings.json tenant ID and make sure you didn't accidentally copy more than you need for the tenant ID.

    0 讨论(0)
  • 2020-12-17 22:04

    Rebuilding my SSO project fixed my problem. Nuget packages were restored as well during rebuilding the project. Hope this helps you.

    0 讨论(0)
  • 2020-12-17 22:04

    In case this helps anybody else.

    I got this error after upgrading a project to .net core 2.0

    the fix.

    Change the name of the instance within appsettings.json instead of

    "AADInstance": "https://login.microsoftonline.com/"

    use

    "Instance": "https://login.microsoftonline.com/"

    0 讨论(0)
提交回复
热议问题