我决定尝试新的Google Oauth2中间件,它几乎破坏了所有内容。这是我从startup.auth.cs提供的配置文件。打开时,包括Google提供程序在内的所有提供程序都会在挑战中获得500个内部服务器。但是,内部服务器错误的细节不可用,我不知道如何打开Katana中间件的任何调试或跟踪。对我来说,就像他们急于将Google Oauth中间件出门一样。GoogleOauth2问题获取内部服务器500错误
//// GOOGLE
var googleOptions = new GoogleOAuth2AuthenticationOptions
{
ClientId = "228",
ClientSecret = "k",
CallbackPath = new PathString("https://stackoverflow.com/users/epsignin")
SignInAsAuthenticationType = DefaultAuthenticationTypes.ExternalCookie,
Provider = new GoogleOAuth2AuthenticationProvider
{
OnAuthenticated = context =>
{
foreach (var x in context.User)
{
string claimType = string.Format("urn:google:{0}", x.Key);
string claimValue = x.Value.ToString();
if (!context.Identity.HasClaim(claimType, claimValue))
context.Identity.AddClaim(new Claim(claimType, claimValue, XmlSchemaString, "Google"));
}
return Task.FromResult(0);
}
}
};
app.UseGoogleAuthentication(googleOptions);
ActionMethod代码:
[AllowAnonymous]
public ActionResult ExternalProviderSignIn(string provider, string returnUrl)
{
var ctx = Request.GetOwinContext();
ctx.Authentication.Challenge(
new AuthenticationProperties
{
RedirectUri = Url.Action("EPSignIn", new { provider })
},
provider);
return new HttpUnauthorizedResult();
}
我不确定具体问题是什么 - 您可以尝试设置Google软件包的符号并查看它出错的位置。以下是一些设置katana符号的说明 - https://katanaproject.codeplex.com/wikipage?title=Debugging&referringTitle=Documentation – Praburaj
这似乎是CallBackPath的一个问题。是否有可能为此提供商设置回叫路径时,它将为所有提供商全局设置该支持。没有深入src,只是一个想法... – CrazyCoderz
当你说全球所有提供商的道具=>你想同样为所有提供者设置?没有办法为所有提供者自动设置相同的内容,但如果需要,可以手动设置它们。你应该确保你有这个redirect uri被注册到各个门户的相应应用程序设置中。如果您没有明确提供一个中间件,则每个中间件都有默认的CallBackPath。例如,这个谷歌中间件的默认值是/ signin-google。 – Praburaj