Identity Server 4: There was an error – invalid_scope

December 29, 2018 0 By Toby Worth

When trying to validate a request against an API, I’m getting this error from the IS4 host.

Sorry, there was an error : invalid_scope

All I’ve done it change the client config to use EF SQL storage, instead of in-memory. During setup/seeding, I’m iterating over the Config class methods to get the configuration and inserting that into the database, there shouldn’t be a difference in the run-time state of Identity Server, but clearly there is.

Turns out this is linked to the same problems I was having with the switch between In-memory storage and EF storage. Errors are thrown during seeding and some of the scopes aren’t actually being created via EF due to the mapping of models to entities (and the construction of the models).

See also: Can’t insert duplicate key row in object dbo.ApiScopes