question related to this post here: Configure the authorization server endpoint.
Using the above example I am able to get token. previously it was possible to get additional information by over riding
public override Task TokenEndpoint(OAuthTokenEndpointContext context)
{
foreach (KeyValuePair<string, string> property in context.Properties.Dictionary)
{
context.AdditionalResponseParameters.Add(property.Key, property.Value);
}
return Task.FromResult<object>(null);
}
how do you achieve that in the current implementation of
public override Task TokenEndpoint(TokenEndpointContext context){
}
Thanks!
Your best option is to directly use the ApplyTokenResponse
event to update the JSON payload returned to the client application. Unlike AdditionalResponseParameters
, it allows you to add - or remove - virtually anything: objects, arrays, strings, integers...
Here's how you can do that:
public override Task ApplyTokenResponse(ApplyTokenResponseContext context)
{
// Only add the custom parameters if the response is not a token error response.
if (string.IsNullOrEmpty(context.Error))
{
context.Response["custom-property-1"] = "custom-value";
context.Response["custom-property-2"] = JArray.FromObject(new[]
{
"custom-value-1",
"custom-value-2"
});
}
return Task.FromResult(0);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With