Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/333.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/34.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# OWIN中OAuthAuthorizationServer的自定义响应_C#_Asp.net_Oauth 2.0_Owin_Katana - Fatal编程技术网

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());
    ...
}