2

I am new to IdentityServer and am having a little trouble setting this up.

For reasons I won't go into here I can't use ASP.NET Identity or EntityFramework. I have a custom database for users that I need to authenticate against so I took the samples and tried to switch out the InMemoryUsers for a custom persistence store.

Here is my ConfigureServices method:

public void ConfigureServices(IServiceCollection services)
{
    services.AddIdentityServer(options =>
        {
            options.AuthenticationOptions = new IdentityServer4.Configuration.AuthenticationOptions
            {
            };
        })
    .AddInMemoryClients(Clients.Get())
    .AddInMemoryScopes(Scopes.Get())
    .SetTemporarySigningCredential();

    services.AddMvc();

    services.AddTransient<ISignInService, SignInService>();
    services.AddTransient<IUserRepository, UserRepository>();
    services.AddTransient<IUserService, UserService>();

    services.AddTransient<IResourceOwnerPasswordValidator, ResourceOwnerPasswordValidator>();
    services.AddTransient<IProfileService, ProfileService>();
}

I know this method is imperfect as I am still testing some things, but when I run the application I get this error:

System.InvalidOperationException No storage mechanism for grants specified. Use the 'AddInMemoryStores' extension method to register a development version.

Obviously I don't want to use in memory stores for a production implementation, but I am not sure what I need to do to fix this.

Tseng
  • 61,549
  • 15
  • 193
  • 205
meyousikmann
  • 821
  • 1
  • 9
  • 30

1 Answers1

3

AddInMemoryStores does not have the best name. It actually adds the store for all the transient data that relates to issued materials/tokens.

We use it in production sometimes because a lot of the time we don't really need to persist this data to disk, and we don't use long lived tokens.

Take a look at what the extension method does here and look at what the IPersistedGrantStore contract looks like to get a better idea.

Lutando
  • 4,909
  • 23
  • 42
  • the extension method link you provided has gone. I am facing the same problem, can you check this [http://stackoverflow.com/questions/40797993/identityserver-4-no-storage-mechanism-for-grants-specified-use-addinmemorysto] – Hussein Salman Nov 25 '16 at 04:59
  • @h.salman the APIs changed literally in the last couple of weeks. Thanks for letting me know I changed the URL – Lutando Nov 25 '16 at 05:27
  • Posted link seems dead ;( – DrCopyPaste Jun 15 '17 at 08:50