我想要以下架构(我已经为这个例子编写了产品名称):
在一台服务器 http://api.prettypictures.com 上运行的Web API 2应用程序
MVC 5客户端应用程序在另一台服务器上运行 http://www.webpics.com
我希望www.webpics.com客户端应用程序使用Pretty Pictures API:
所有上述工作除了在Facebook,Google等注册外部账户外.
我无法确定从API的单独客户端用户创建外部帐户的正确流程.
我已经研究了认证流程中可用的大多数文档,如下所示:

我已经在OWIN的新身份模型上阅读了我所能做的一切.
我已经在Visual Studio 2013中检查了SPA模板.它演示了如何完成我需要的大部分工作,但仅限于客户端和API在同一主机上时; 如果我希望多个客户端访问我的API并且能够让用户通过Google等注册,那么它就无法正常工作,而且我可以告诉OWIN身份验证流程中断.
到目前为止流程如下:
这是我被卡住的地方.接下来应该发生的是以某种方式通知客户端应用程序用户已成功通过google.com进行身份验证,并获得一次性访问代码以便稍后交换访问令牌.如有必要,客户端应用程序应该有机会提示用户输入与google.com登录相关联的用户名.
我不知道如何促进这一点.
实际上,此时浏览器在谷歌回调后最终坐在api.prettypictures.com/Account/ExternalLogin端点上.该API已登录Google,但客户端不知道如何处理该问题.我应该将该饼干送回www.webpics.com吗?
在SPA应用程序中,它通过AJAX完成,google.com将返回一个令牌作为URL片段,它一切运行良好,因为它都在一个域上.但这远远超过了拥有多个客户可以充分利用的"API"的重要性.
救命!
asp.net-mvc oauth-2.0 owin asp.net-identity asp.net-web-api2
我试图将我的所有ASP MVC HTTP响应标头更改为默认情况下具有另一个值,以便在我的博客应用程序中实现Pingback自动发现.
默认标头(在Cassini上)是:
Cache-Control private
Connection Close
Content-Length 20901
Content-Type text/html; charset=utf-8
Date Fri, 20 Apr 2012 22:46:11 GMT
Server ASP.NET Development Server/10.0.0.0
X-AspNet-Version 4.0.30319
X-AspNetMvc-Version 3.0
Run Code Online (Sandbox Code Playgroud)
我想要一个额外的增值:
X-Pingback: http://localhost:4912/pingback/xmlrpcserver
Run Code Online (Sandbox Code Playgroud)
我已经google了一下,找到了一个neet解决方案: - 从ActionFilterAttribute派生并覆盖OnResultExecuted方法:
public class HttpHeaderAttribute : ActionFilterAttribute
{
public string Name { get; set; }
public string Value { get; set; }
public HttpHeaderAttribute(string name, string value)
{
Name = name;
Value = value;
}
public override void OnResultExecuted(ResultExecutedContext filterContext)
{
filterContext.HttpContext.Request.Headers.Add(Name, Value);
base.OnResultExecuted(filterContext); …Run Code Online (Sandbox Code Playgroud)