覆盖AspNet.Security.OpenIdConnect.Server中的TokenEndPoint
与此帖相关的问题: 配置授权服务器端点 。
使用上面的例子,我可以得到令牌。 以前可以通过骑马获得额外的信息
public override Task TokenEndpoint(OAuthTokenEndpointContext context) { foreach (KeyValuePair property in context.Properties.Dictionary) { context.AdditionalResponseParameters.Add(property.Key, property.Value); } return Task.FromResult(null); }
你如何在当前的实施中实现这一目标
public override Task TokenEndpoint(TokenEndpointContext context){ }
谢谢!
您最好的选择是直接使用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); }
- 从.NET Core / ASP.NET Core中的类库访问App密钥数据
- OpenIdConnectAuthenticationHandler:message.State为null或为空
- 启用asp.net核心请求validation
- entity framework核心仍然采用旧列
- 通过Service Fabric项目进行调试时未使用的环境变量
- ASP.NET Core 0x80004005
- WebHostBuilder。 如何在.NET-Core 2.0中使用CommandLine设置URL地址?
- 如何使用Web API Get方法返回图像
- DNX SDK版本’dnx-clr-win-x86.1.0.0-beta8-15530’无法安装