AuthenticationManager.GetExternalLoginInfoAsync()始终为空
ExternalLoginInfo loginInfo = await AuthenticationManager.GetExternalLoginInfoAsync();
为什么这行总是返回null?它发生在用户尝试使用任何提供者登录时。我知道FLOW是正确的,因为它实际上在本地工作,但是当我部署网站时,它总是返回null。AuthenticationManager.GetExternalLoginInfoAsync()始终为空
从我所了解的情况来看,它使用外部cookie来跟踪这一点,我可以确定它不是浏览器,因为它在本地工作在同一浏览器上。
即使我已经仔细检查了所有提供者在每个相应的控制面板中都具有“允许”域,也会发生这种情况。就像我说的一切都在当地工作。
我试过重新启动IIS,因为一些答案建议。
也有这些线Startup.Auth.cs与cookie DOMIAN正确设置
app.UseCookieAuthentication(new CookieAuthenticationOptions {
CookieDomain = ".example.com",
...
});
//use a cookie to temporarily store information about a user logging in with a third party login provider
app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);
回答:
确保您(Facebook,微博等)供应商设置未覆盖的部署。
此外请确保您的回调网址在提供商处正确注册。我正在使用LinkedIn,需要一个完整的URL到你的回调,例如。 https://domain.com/signin-linkedin
我有以下设置,这没有任何问题的工作:
app.UseCookieAuthentication(new CookieAuthenticationOptions {
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
CookieSecure = CookieSecureOption.SameAsRequest,
CookieName = "CustomCookieName",
LoginPath = new PathString("/Account/Login"),
Provider = new CookieAuthenticationProvider
{
OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<ApplicationUserManager, User>(
validateInterval: TimeSpan.FromMinutes(30),
regenerateIdentity: (manager, user) => Some.Custom.Identity.Helper.GenerateUserIdentityHelperAsync(user, manager)) // This helper method returns ClaimsIdentity for the user
}
});
app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);
以上是 AuthenticationManager.GetExternalLoginInfoAsync()始终为空 的全部内容, 来源链接: utcz.com/qa/258000.html