C# OWIN中OAuthAuthorizationServer的自定义响应
我需要在C# OWIN中OAuthAuthorizationServer的自定义响应,c#,asp.net,oauth-2.0,owin,katana,C#,Asp.net,Oauth 2.0,Owin,Katana,我需要在OAuthAuthorizationServer 默认响应如下所示 { "access_token": "***access_token***", "token_type": "bearer", "expires_in": 119, ".issued": "Mon, 31 Oct 2016 11:20:50 GMT", ".expires": "Mon, 31 Oct 2016 11:22:50 GMT" } 如何生成此输出而不是默认输出 { "message"
OAuthAuthorizationServer
默认响应如下所示
{
"access_token": "***access_token***",
"token_type": "bearer",
"expires_in": 119,
".issued": "Mon, 31 Oct 2016 11:20:50 GMT",
".expires": "Mon, 31 Oct 2016 11:22:50 GMT"
}
如何生成此输出而不是默认输出
{
"message": "Token Granted",
"data":
{
"Token": "***access_token***"
},
"messageCode": 200
}
这个问题类似于 请看我的答案 此外,您可以解析响应json而不是使用字符串,例如:
public async Task Invoke(HttpContext context)
{
...
// parse json
var bodyJson = JObject.Parse(bodyString);
// do something with json inner objects
bodyJson = ...
// update the memory stream
var bytes = Encoding.UTF8.GetBytes(bodyJson.ToString());
...
}