asp.net – GetExternalLoginInfoAsync()loginInfo返回null – 但仅在几个
|
我正在使用Strava作为我的外部登录提供商(我认为这与Strava无关,也可能是google或facebook)运行几小时/几天甚至几周后,GetExternalLoginInfoAsync返回null.我已经阅读了同样问题的一堆其他问题,但没有找到解决方案.我发布了我的整个ConfigureAuth方法,以防我在订单上做错了. 如果你有一个strava帐户,你可能会在这里遇到问题:fartslek.no/Account/Login public void ConfigureAuth(IAppBuilder app)
{
// Configure the db context,user manager and signin manager to use a single instance per request
app.CreatePerOwinContext(ApplicationDbContext.Create);
app.CreatePerOwinContext<ApplicationUserManager>(ApplicationUserManager.Create);
app.CreatePerOwinContext<ApplicationSignInManager>(ApplicationSignInManager.Create);
// Enable the application to use a cookie to store information for the signed in user
// and to use a cookie to temporarily store information about a user logging in with a third party login provider
// Configure the sign in cookie
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,LoginPath = new PathString("/Account/Login"),Provider = new CookieAuthenticationProvider
{
// Enables the application to validate the security stamp when the user logs in.
// This is a security feature which is used when you change a password or add an external login to your account.
OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<ApplicationUserManager,ApplicationUser>(
validateInterval: TimeSpan.FromMinutes(30),regenerateIdentity: (manager,user) => user.GenerateUserIdentityAsync(manager))
},CookieManager = new SystemWebCookieManager()
});
app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);
app.UseTwoFactorSignInCookie(DefaultAuthenticationTypes.TwoFactorCookie,TimeSpan.FromMinutes(5));
app.UseTwoFactorRememberBrowserCookie(DefaultAuthenticationTypes.TwoFactorRememberBrowserCookie);
app.UseStravaAuthentication( new StravaAuthenticationOptions{
ClientId="XXX",ClientSecret= "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF",});
}
我正在使用这个https://github.com/Johnny2Shoes/Owin.Security.Strava来获得StravaAuth. 当它停止工作时,天蓝色的重置是不够的,但是如果我进行新的部署,一切都会工作一段时间. 我正在使用Owin 3.0.1和Mvc 5.2.3 解决方法我有同样的问题.谷歌搜索了一下后,我发现这是Owin的一个已知错误,因为他们处理cookie的方式.This issue被提交给Katana团队,但看起来他们根本不会修复它.有很多解决方法,但这是我能找到的最简单的方法: [HttpPost]
[AllowAnonymous]
[ValidateAntiForgeryToken]
public ActionResult ExternalLogin(string provider,string returnUrl)
{
ControllerContext.HttpContext.Session.RemoveAll();
// Request a redirect to the external login provider
return new ChallengeResult(provider,Url.Action("ExternalLoginCallback","Account",new { ReturnUrl = returnUrl }));
}
有关此错误的更多详细信息,请参阅this问题,如果适合您,请告诉我. (编辑:莱芜站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
- asp.net-mvc – ASP.NET MVC中的Windows Live ID
- asp.net-mvc – ASP.NET MVC应用程序的WatiN最佳实践/经验法
- ASP.Net下载大文件的实现方法
- asp.net-mvc-2 – 带有数组/列表的ASP.NET MVC 2模型
- asp.net – Session Timeout .NET
- asp.net – “’Microsoft.Jet.OLEDB.4.0’提供程序未在本地
- ASP.NET -- WebForm -- HttpResponse 类的方法和属性
- asp.net-mvc-3 – Telerik MVC网格,在运行时从集合或字典中
- asp.net-mvc – ASP.net MVC DropDownList预选项目被忽略
- C# 中的委托和事件 [转载]
