BHR*_*BHR 5 c# openid openid-connect aspnet-contrib asp.net-core
与此帖子相关的问题:配置授权服务器端点.
使用上面的例子,我可以得到令牌.以前可以通过骑马获得额外的信息
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);
}
Run Code Online (Sandbox Code Playgroud)
你如何在当前的实施中实现这一目标
public override Task TokenEndpoint(TokenEndpointContext context){
}
Run Code Online (Sandbox Code Playgroud)
谢谢!
您最好的选择是直接使用该ApplyTokenResponse事件来更新返回给客户端应用程序的 JSON 负载。不像AdditionalResponseParameters,它允许您添加或删除几乎所有内容:对象、数组、字符串、整数...
您可以这样做:
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);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2019 次 |
| 最近记录: |