Passing additional data with reference tokens in Identity Server 4

前端 未结 1 1312
再見小時候
再見小時候 2021-01-25 00:32

I am using reference tokens on my Identity Server and want to pass some additional data to the client.

I know how to do this with a JWT by setting claims in my Profile S

1条回答
  •  梦毁少年i
    2021-01-25 00:48

    You can implement (and register) the ICustomTokenRequestValidator interface which could help adding custom response parameters :

    public class DefaultClientClaimsAdder : ICustomTokenRequestValidator
    {
        public Task ValidateAsync(CustomTokenRequestValidationContext context)
        {
            context.Result.CustomResponse = new Dictionary
            {
                {"hello", "world" }
            };
    
            return Task.FromResult(0);
        }
    }
    

    Register it in Startup.cs in identity server app:

    services.AddTransient();
    

    The custom property will include in token response :

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