Passing additional data with reference tokens in Identity Server 4

前端 未结 1 1297
再見小時候
再見小時候 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条回答
  • 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<string, object>
            {
                {"hello", "world" }
            };
    
            return Task.FromResult(0);
        }
    }
    

    Register it in Startup.cs in identity server app:

    services.AddTransient<ICustomTokenRequestValidator, DefaultClientClaimsAdder>();
    

    The custom property will include in token response :

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