IdentityServer4 - How to store refresh token into database using mysql.data?

前端 未结 2 619
隐瞒了意图╮
隐瞒了意图╮ 2021-01-18 16:09

I\'m new at IdentityServer4. I read I need to implement an IPersistedGrantStore to store refresh tokens into a table like PersistedGrants in my dat

相关标签:
2条回答
  • 2021-01-18 16:24

    The key will be to implement IPersistedGrantStore using whatever backend you like, then to tell IdentityServer to use that implementation by registering the implementation in the dependency injection system.

    For example, if you call your implementation PersistedGrantStore, then you could register the implementation like this:

    services.AddTransient<IPersistedGrantStore, PersistedGrantStore>();

    You can see that essentially this is all that the EntityFramework implementation does, once you take away all the EntityFramework stuff.

    Later when IdentityServer wants to persist a grant, it will get your implementation and call the appropriate method. So you don't have to do anything, other than inject your implementation into IdentityServer so it can do whats needed.

    0 讨论(0)
  • 2021-01-18 16:28

    I know the question is kind of old and you might have already found the problem. I think your only mistake is that you invented your own interface instead of implementing:

    IdentityServer4.Stores.IPersistedGrantStore
    

    If you want to use your own CustomPersistedGrant it should derive from:

    IdentityServer4.Models.PersistedGrant
    

    otherwise you would have to wrap it somehow.

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