我決定嘗試新的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