问题描述
与此帖子相关的问题:配置授权服务器端点.
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);
}
您如何在
public override Task TokenEndpoint(TokenEndpointContext context){
}
谢谢!
推荐答案
您最好的选择是直接使用ApplyTokenResponse
事件更新返回给客户端应用程序的JSON有效负载.与AdditionalResponseParameters
不同,它允许您添加或删除几乎所有内容:对象,数组,字符串,整数...
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);
}
这篇关于覆盖AspNet.Security.OpenIdConnect.Server中的TokenEndPoint的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!