简体   繁体   中英

Custom Token Response on Token Endpoint

Is there a way to achieve the below response on Token Endpoint?

{
  "access_token": "reirhnfslker3874hdjw8o",
  "expires_in": 3600,
  "refresh_token": "43wi9jd38du83wjd38d",
  "id_token": "3yc3u4mc83u4820ic2i3409muc28yc28h532y...",
  "custom_response": "test"
}

I already tried using ICustomTokenRequestValidator but it didn't worked

public class CustomTokenRequestValidator : ICustomTokenRequestValidator
    {
        public async Task<CustomTokenRequestValidationContext> ValidateAsync(CustomTokenRequestValidationContext context)
        {
            context.Result.CustomResponse = new Dictionary<string, object> { { "custom_response", "test" } };

            return context;
        }

        Task ICustomTokenRequestValidator.ValidateAsync(CustomTokenRequestValidationContext context)
        {
            return ValidateAsync(context);
        }
    }

You can implement the ITokenResponseGenerator interface and either store information in the Custom entries property of the Token Response Model

Or just have this interface return your own version of TokenResponse model

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM