jelliaes
jelliaes

Reputation: 505

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);
        }
    }

Upvotes: 0

Views: 473

Answers (1)

Dave Morrison
Dave Morrison

Reputation: 179

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

Upvotes: 1

Related Questions