【发布时间】:2015-04-23 18:49:10
【问题描述】:
我想从令牌端点响应中修改响应正文。
我尝试使用 MessageHandler 拦截 /Token 请求,但它不起作用。
我可以通过覆盖OAuthAuthorizationServerProvider.TokenEndpoint方法向响应中添加一些附加信息,但我无法创建自己的响应正文。
有没有办法拦截/Token请求?
编辑
我发现了如何从令牌端点响应中删除响应正文内容,如下所示:HttpContext.Current.Response.SuppressContent = true;
这似乎是实现我的目标的正确方法,但现在当我使用context.AdditionalResponseParameters.Add() 方法添加我的自定义信息时,SuppressContent 会阻止任何更改。
现在我有这样的东西:
// Removing the body from the token endpoint response
HttpContext.Current.Response.SuppressContent = true;
// Add custom informations
context.AdditionalResponseParameters.Add("a", "test");
【问题讨论】:
标签: asp.net asp.net-web-api oauth-2.0 owin http-token-authentication