Asp.net web api ASP.NET web API标识外部登录重定向
我使用ASP.NETWebAPI身份登录Facebook,我有angularjs应用程序 当我打电话时Asp.net web api ASP.NET web API标识外部登录重定向,asp.net-web-api,asp.net-identity-2,Asp.net Web Api,Asp.net Identity 2,我使用ASP.NETWebAPI身份登录Facebook,我有angularjs应用程序 当我打电话时 MainURL + 'api/Account/ExternalLogins?returnUrl=%2F&generateState=true' 我不想返回web API页面,而是希望Facebook将我重定向回我的angularJS应用程序,所以我这样做了: [AllowAnonymous] [Route("ExternalLogins")] public IEnu
MainURL + 'api/Account/ExternalLogins?returnUrl=%2F&generateState=true'
我不想返回web API页面,而是希望Facebook将我重定向回我的angularJS应用程序,所以我这样做了:
[AllowAnonymous]
[Route("ExternalLogins")]
public IEnumerable<ExternalLoginViewModel> GetExternalLogins(string returnUrl, bool generateState = false)
{
IEnumerable<AuthenticationDescription> descriptions = Authentication.GetExternalAuthenticationTypes();
List<ExternalLoginViewModel> logins = new List<ExternalLoginViewModel>();
string state;
if (generateState)
{
const int strengthInBits = 256;
state = RandomOAuthStateGenerator.Generate(strengthInBits);
}
else
{
state = null;
}
foreach (AuthenticationDescription description in descriptions)
{
ExternalLoginViewModel login = new ExternalLoginViewModel
{
Name = description.Caption,
Url = Url.Route("ExternalLogin", new
{
provider = description.AuthenticationType,
response_type = "token",
client_id = Startup.PublicClientId,
redirect_uri = new Uri("http://localhost:6263/com.html").AbsoluteUri,
// redirect_uri = new Uri(Request.RequestUri, returnUrl).AbsoluteUri,
state = state
}),
State = state
};
logins.Add(login);
}
return logins;
}
我肯定这已经晚了。看看你的url,它有一个双斜杠(//)我确信这已经晚了。看看你的url,它有一个双斜杠(//)
/api/Account/ExternalLogin?provider=Facebook&response_type=token&client_id=self&redirect_uri=localhost%3A6263%2Fcom.html&state=j0y0wF0yhvA_tzqbJo0GijCecqfbNWT0vLQiXxcHDqM1