I have application that used the nuget packages IdentityServer4 2.2.0, IdentityServer4.AccessTokenValidation 2.6.0 and IdentityServer4.EntityFramework 2.1.1, thay also used automapper 7.0.1. I updated them to IdentityServer4 2.3.2, IdentityServer4.AccessTokenValidation 2.7.0 and IdentityServer4.EntityFramework 2.3.2, thay also used automapper 8.0.0 and got this error
HttpRequestException: Response status code does not indicate success: 500 (Internal Server Error).
System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()
Microsoft.IdentityModel.Protocols.HttpDocumentRetriever.GetDocumentAsync(string address, CancellationToken cancel)
Show raw exception details
IOException: IDX20804: Unable to retrieve document from: 'http://localhost:5000/.well-known/openid-configuration'.
Microsoft.IdentityModel.Protocols.HttpDocumentRetriever.GetDocumentAsync(string address, CancellationToken cancel)
Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectConfigurationRetriever.GetAsync(string address, IDocumentRetriever retriever, CancellationToken cancel)
Microsoft.IdentityModel.Protocols.ConfigurationManager
Show raw exception details
InvalidOperationException: IDX20803: Unable to obtain configuration from: 'http://localhost:5000/.well-known/openid-configuration'.
Microsoft.IdentityModel.Protocols.ConfigurationManager
Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectHandler.HandleChallengeAsync(AuthenticationProperties properties)
Microsoft.AspNetCore.Authentication.AuthenticationHandler
Microsoft.AspNetCore.Authentication.AuthenticationService.ChallengeAsync(HttpContext context, string scheme, AuthenticationProperties properties)
Microsoft.AspNetCore.Mvc.ChallengeResult.ExecuteResultAsync(ActionContext context)
Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeResultAsync(IActionResult result)
Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeAlwaysRunResultFilters()
Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeFilterPipelineAsync()
Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeAsync()
Microsoft.AspNetCore.Builder.RouterMiddleware.Invoke(HttpContext httpContext)
Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.Invoke(HttpContext context)
Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
I'm using my Identity server with
.AddConfigurationStore(options =>
{
options.DefaultSchema = "IDN";
options.ConfigureDbContext = b =>
b.UseSqlServer(connectionString,
sql => sql.MigrationsAssembly(migrationsAssembly));
})
//this adds the operational data from DB (codes, tokens, consents)
.AddOperationalStore(options =>
{
options.DefaultSchema = "IDN";
options.ConfigureDbContext = b =>
b.UseSqlServer(connectionString,
sql => sql.MigrationsAssembly(migrationsAssembly));
// this enables automatic token cleanup. this is optional.
options.EnableTokenCleanup = true;
options.TokenCleanupInterval = 60;
})
And I saw that you changed the Client tables but I cannot find the data model again. I tried to use in memory clients instead but I was getting the same error.
I had to rollback all IDS4 nuget packages and also automapper because IdentityServer4.EntityFramework.Storage depends on it and fails if I use a newer version of automapper.
I also tried to upgrade some old tutorial projects from 2.2.0 to 2.3.2 and I get the same Unable to retrieve document from: 'http://localhost:5000/.well-known/openid-configuration'.
Is there anything else I have to change in the projects apart from upgrading the nuget packages in order to make them work?
Check your identity server logs
You're getting the same error as me, db needs updating
https://github.com/IdentityServer/IdentityServer4/issues/2879
I got the db error
Error Number:207,State:1,Class:16
2018-12-05 17:59:18.049 +01:00 [INF] {"Details":"System.Data.SqlClient.SqlException (0x80131904): Invalid column name 'Created'.\r\nInvalid column name 'NonEditable'.\r\nInvalid column name 'Updated'.\r\n at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action1 wrapCloseInAction)\r\n at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action1 wrapCloseInAction)\r\n at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)\r\n at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)\r\n at System.Data.SqlClient.SqlDataReader.TryConsumeMetaData()\r\n at System.Data.SqlClient.SqlDataReader.get_MetaData()\r\n at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)\r\n at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, SqlDataReader ds)\r\n at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, TaskCompletionSource1 completion, Int32 timeout, Task& task, Boolean asyncWrite, String method)\r\n at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior)\r\n at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)\r\n at Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.Execute(IRelationalConnection connection, DbCommandMethod executeMethod, IReadOnlyDictionary2 parameterValues)\r\n at Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.ExecuteReader(IRelationalConnection connection, IReadOnlyDictionary2 parameterValues)\r\n at Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable1.Enumerator.BufferlessMoveNext(DbContext _, Boolean buffer)\r\n at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerExecutionStrategy.ExecuteTState,TResult\r\n at Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable1.Enumerator.MoveNext()\r\n at System.Linq.Enumerable.SelectEnumerableIterator2.MoveNext()\r\n at Microsoft.EntityFrameworkCore.Query.Internal.LinqOperatorProvider._TrackEntitiesTOut,TIn\r\n at System.Collections.Generic.EnumerableHelpers.ToArrayT\r\n at IdentityServer4.EntityFramework.Stores.ResourceStore.GetAllResourcesAsync() in C:\local\identity\server4\EntityFramework.Storage\src\Stores\ResourceStore.cs:line 138\r\n at IdentityServer4.Stores.IResourceStoreExtensions.GetAllEnabledResourcesAsync(IResourceStore store) in C:\local\identity\server4\IdentityServer4\src\Extensions\IResourceStoreExtensions.cs:line 105\r\n at IdentityServer4.ResponseHandling.DiscoveryResponseGenerator.CreateDiscoveryDocumentAsync(String baseUrl, String issuerUri) in C:\local\identity\server4\IdentityServer4\src\ResponseHandling\Default\DiscoveryResponseGenerator.cs:line 169\r\n at IdentityServer4.Endpoints.DiscoveryEndpoint.ProcessAsync(HttpContext context) in C:\local\identity\server4\IdentityServer4\src\Endpoints\DiscoveryEndpoint.cs:line 58\r\n at IdentityServer4.Hosting.IdentityServerMiddleware.Invoke(HttpContext context, IEndpointRouter router, IUserSession session, IEventService events) in C:\local\identity\server4\IdentityServer4\src\Hosting\IdentityServerMiddleware.cs:line 54\r\nClientConnectionId:2b4462cb-d849-4d54-9610-dcd0e6f104de\r\nError Number:207,State:1,Class:16","Category":"Error","Name":"Unhandled Exception","EventType":"Error","Id":3000,"Message":"Invalid column name 'Created'.\r\nInvalid column name 'NonEditable'.\r\nInvalid column name 'Updated'.","ActivityId":"0HLIQQBS6FP42:00000001","TimeStamp":"2018-12-05T16:59:18.0000000Z","ProcessId":15172,"LocalIpAddress":"::1:5000","RemoteIpAddress":"::1","$type":"UnhandledExceptionEvent"}
2018-12-05 17:59:18.076 +01:00 [FTL] Unhandled exception: Invalid column name 'Created'.
Invalid column name 'NonEditable'.
Invalid column name 'Updated'.
System.Data.SqlClient.SqlException (0x80131904): Invalid column name 'Created'.
Invalid column name 'NonEditable'.
Invalid column name 'Updated'.
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action1 wrapCloseInAction)
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action1 wrapCloseInAction)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
at System.Data.SqlClient.SqlDataReader.TryConsumeMetaData()
at System.Data.SqlClient.SqlDataReader.get_MetaData()
at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, SqlDataReader ds)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, TaskCompletionSource1 completion, Int32 timeout, Task& task, Boolean asyncWrite, String method)
at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior)
at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
at Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.Execute(IRelationalConnection connection, DbCommandMethod executeMethod, IReadOnlyDictionary2 parameterValues)
at Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.ExecuteReader(IRelationalConnection connection, IReadOnlyDictionary2 parameterValues)
at Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable1.Enumerator.BufferlessMoveNext(DbContext _, Boolean buffer)
at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerExecutionStrategy.ExecuteTState,TResult
at Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable1.Enumerator.MoveNext()
at System.Linq.Enumerable.SelectEnumerableIterator2.MoveNext()
at Microsoft.EntityFrameworkCore.Query.Internal.LinqOperatorProvider._TrackEntitiesTOut,TIn
at System.Collections.Generic.EnumerableHelpers.ToArrayT
at IdentityServer4.EntityFramework.Stores.ResourceStore.GetAllResourcesAsync() in C:\local\identity\server4\EntityFramework.Storage\src\Stores\ResourceStore.cs:line 138
at IdentityServer4.Stores.IResourceStoreExtensions.GetAllEnabledResourcesAsync(IResourceStore store) in C:\local\identity\server4\IdentityServer4\src\Extensions\IResourceStoreExtensions.cs:line 105
at IdentityServer4.ResponseHandling.DiscoveryResponseGenerator.CreateDiscoveryDocumentAsync(String baseUrl, String issuerUri) in C:\local\identity\server4\IdentityServer4\src\ResponseHandling\Default\DiscoveryResponseGenerator.cs:line 169
at IdentityServer4.Endpoints.DiscoveryEndpoint.ProcessAsync(HttpContext context) in C:\local\identity\server4\IdentityServer4\src\Endpoints\DiscoveryEndpoint.cs:line 58
at IdentityServer4.Hosting.IdentityServerMiddleware.Invoke(HttpContext context, IEndpointRouter router, IUserSession session, IEventService events) in C:\local\identity\server4\IdentityServer4\src\Hosting\IdentityServerMiddleware.cs:line 54
ClientConnectionId:2b4462cb-d849-4d54-9610-dcd0e6f104de
But then I changed my clients to InMemory clients and I continued to get the http://localhost:5000/.well-known/openid-configuration error
Then my log file shows
2018-12-05 15:53:58.814 +01:00 [INF] {
"Name": "Unhandled Exception",
"Category": "Error",
"EventType": "Error",
"Id": 3000,
"Details": "System.Exception: Duplicate API scopes found. This is an invalid configuration. Use different names for API scopes. Scopes found: MyCompany.MyProject.Gateways.Maintenance, MyCompany.MyProject.Gateways.Scheduling\r\n at IdentityServer4.Stores.IResourceStoreExtensions.CheckForDuplicates(String[] identityScopeNames, String[] apiScopeNames) in C:\local\identity\server4\IdentityServer4\src\IdentityServer4\Extensions\IResourceStoreExtensions.cs:line 83\r\n at IdentityServer4.Stores.IResourceStoreExtensions.Validate(IEnumerable1 identity, IEnumerable1 apiResources) in C:\local\identity\server4\IdentityServer4\src\IdentityServer4\Extensions\IResourceStoreExtensions.cs:line 49\r\n at IdentityServer4.Stores.IResourceStoreExtensions.GetAllEnabledResourcesAsync(IResourceStore store) in C:\local\identity\server4\IdentityServer4\src\IdentityServer4\Extensions\IResourceStoreExtensions.cs:line 108\r\n at IdentityServer4.ResponseHandling.DiscoveryResponseGenerator.CreateDiscoveryDocumentAsync(String baseUrl, String issuerUri) in C:\local\identity\server4\IdentityServer4\src\IdentityServer4\ResponseHandling\DiscoveryResponseGenerator.cs:line 164\r\n at IdentityServer4.Endpoints.DiscoveryEndpoint.ProcessAsync(HttpContext context) in C:\local\identity\server4\IdentityServer4\src\IdentityServer4\Endpoints\DiscoveryEndpoint.cs:line 58\r\n at IdentityServer4.Hosting.IdentityServerMiddleware.Invoke(HttpContext context, IEndpointRouter router, IUserSession session, IEventService events) in C:\local\identity\server4\IdentityServer4\src\IdentityServer4\Hosting\IdentityServerMiddleware.cs:line 54",
"Message": "Duplicate API scopes found. This is an invalid configuration. Use different names for API scopes. Scopes found: MyCompany.MyProject.Gateways.Maintenance, MyCompany.MyProject.Gateways.Scheduling",
"ActivityId": "0HLIQO5QL81L1:00000002",
"TimeStamp": "2018-12-05T14:53:58Z",
"ProcessId": 19756,
"LocalIpAddress": "127.0.0.1:35506",
"RemoteIpAddress": "::1"
}
2018-12-05 15:53:58.814 +01:00 [FTL] Unhandled exception: Duplicate API scopes found. This is an invalid configuration. Use different names for API scopes. Scopes found: MyCompany.MyProject.Gateways.Maintenance, MyCompany.MyProject.Gateways.Scheduling
System.Exception: Duplicate API scopes found. This is an invalid configuration. Use different names for API scopes. Scopes found: MyCompany.MyProject.Gateways.Maintenance, MyCompany.MyProject.Gateways.Scheduling
at IdentityServer4.Stores.IResourceStoreExtensions.CheckForDuplicates(String[] identityScopeNames, String[] apiScopeNames) in C:\local\identity\server4\IdentityServer4\src\IdentityServer4\Extensions\IResourceStoreExtensions.cs:line 83
at IdentityServer4.Stores.IResourceStoreExtensions.Validate(IEnumerable1 identity, IEnumerable1 apiResources) in C:\local\identity\server4\IdentityServer4\src\IdentityServer4\Extensions\IResourceStoreExtensions.cs:line 49
at IdentityServer4.Stores.IResourceStoreExtensions.GetAllEnabledResourcesAsync(IResourceStore store) in C:\local\identity\server4\IdentityServer4\src\IdentityServer4\Extensions\IResourceStoreExtensions.cs:line 108
at IdentityServer4.ResponseHandling.DiscoveryResponseGenerator.CreateDiscoveryDocumentAsync(String baseUrl, String issuerUri) in C:\local\identity\server4\IdentityServer4\src\IdentityServer4\ResponseHandling\DiscoveryResponseGenerator.cs:line 164
at IdentityServer4.Endpoints.DiscoveryEndpoint.ProcessAsync(HttpContext context) in C:\local\identity\server4\IdentityServer4\src\IdentityServer4\Endpoints\DiscoveryEndpoint.cs:line 58
at IdentityServer4.Hosting.IdentityServerMiddleware.Invoke(HttpContext context, IEndpointRouter router, IUserSession session, IEventService events) in C:\local\identity\server4\IdentityServer4\src\IdentityServer4\Hosting\IdentityServerMiddleware.cs:line 54
2018-12-05 15:54:02.846 +01:00 [ERR] An unhandled exception has occurred while executing the request.
System.Exception: Duplicate API scopes found. This is an invalid configuration. Use different names for API scopes. Scopes found: MyCompany.MyProject.Gateways.Maintenance, MyCompany.MyProject.Gateways.Scheduling
at IdentityServer4.Stores.IResourceStoreExtensions.CheckForDuplicates(String[] identityScopeNames, String[] apiScopeNames) in C:\local\identity\server4\IdentityServer4\src\IdentityServer4\Extensions\IResourceStoreExtensions.cs:line 83
at IdentityServer4.Stores.IResourceStoreExtensions.Validate(IEnumerable1 identity, IEnumerable1 apiResources) in C:\local\identity\server4\IdentityServer4\src\IdentityServer4\Extensions\IResourceStoreExtensions.cs:line 49
at IdentityServer4.Stores.IResourceStoreExtensions.GetAllEnabledResourcesAsync(IResourceStore store) in C:\local\identity\server4\IdentityServer4\src\IdentityServer4\Extensions\IResourceStoreExtensions.cs:line 108
at IdentityServer4.ResponseHandling.DiscoveryResponseGenerator.CreateDiscoveryDocumentAsync(String baseUrl, String issuerUri) in C:\local\identity\server4\IdentityServer4\src\IdentityServer4\ResponseHandling\DiscoveryResponseGenerator.cs:line 164
at IdentityServer4.Endpoints.DiscoveryEndpoint.ProcessAsync(HttpContext context) in C:\local\identity\server4\IdentityServer4\src\IdentityServer4\Endpoints\DiscoveryEndpoint.cs:line 58
at IdentityServer4.Hosting.IdentityServerMiddleware.Invoke(HttpContext context, IEndpointRouter router, IUserSession session, IEventService events) in C:\local\identity\server4\IdentityServer4\src\IdentityServer4\Hosting\IdentityServerMiddleware.cs:line 54
at IdentityServer4.Hosting.IdentityServerMiddleware.Invoke(HttpContext context, IEndpointRouter router, IUserSession session, IEventService events) in C:\local\identity\server4\IdentityServer4\src\IdentityServer4\Hosting\IdentityServerMiddleware.cs:line 69
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Cors.Infrastructure.CorsMiddleware.Invoke(HttpContext context)
at IdentityServer4.Hosting.BaseUrlMiddleware.Invoke(HttpContext context) in C:\local\identity\server4\IdentityServer4\src\IdentityServer4\Hosting\BaseUrlMiddleware.cs:line 36
at Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.MigrationsEndPointMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.DatabaseErrorPageMiddleware.Invoke(HttpContext httpContext)
at Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.DatabaseErrorPageMiddleware.Invoke(HttpContext httpContext)
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
My scopes have a similar prefix but they don't have the same name.
The project where I'm working is DB first (not my choice but I'm not allowed to change this). Do you have a SQL script to update the DB?
@ThisNoName that seems like an unrelated error -- can you open a new issue?
@brockallen After some further digging, turned out what I saw was the RedirectUris and PostLogoutRedirectUris required since 2.3. Already addressed in https://github.com/IdentityServer/IdentityServer4/issues/2810
Removed previous post since it's unrelated to this thread. Thanks for your help.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.