Unable to get configuration from well known / openid configuration

I use ASP.NET 5. In my solution, I have a web interface API, Identity Server and Angular 2, and I authenticate the Angular 2 client using Identity Server, the Angular 2 client uses web api by passing the token in the HTTP request and the token authentication authentication web-api and gives the answer, for this I wrote my own attribute that authenticates the user or not

When I use the API, I get the following exception, and the web API returns 500 internal server errors.

System.InvalidOperationException: IDX10803: cannot get configuration from: ' http: //xx.xx.xx.x: 3926 / .well-known / openid-configuration '. ---> System.IO.IOException: IDX10804: cannot get document from: ' http: //xx.xx.xx.x: 3926 / .well-known / openid-configuration'. ---> System.AggregateException: One or more errors occurred. ---> System.Net.Http.HttpRequestException: an error occurred while sending the request. ---> System.Net.WebException: cannot connect to the remote server ---> System.Net.Sockets.SocketException: the connection attempt failed because the connected party did not respond properly after some time or the connection was not established because the connected host could not answer xx.xx.xx.x: 3926 in System.Net.Sockets.Socket.EndConnect (IAsyncResult asyncResult) in System.Net.ServicePoint.ConnectSocketInternal (Boolean connectFailure, Socket s4, Socket s6, Socket & socket, IPAddress & address, state ConnectSocketState, IAsyncResult asyncResult, exception and exception)

+5
6

, .

, .

DelayLoadMetadata .

, .

+11

- , .

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
        });
+2

, - .

.net core 2.0

.

appsettings.json

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

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

+1

. @leastprivilege. , Identity Server . , .

0
source

Restoring my SSO project fixed my problem. Nuget packages were also restored during the restoration of the project. Hope this helps you.

0
source

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

0
source

All Articles