GetExternalLoginInfoAsync() loginInfo 返回 null

编程入门 行业动态 更新时间:2024-10-23 07:34:30
本文介绍了GetExternalLoginInfoAsync() loginInfo 返回 null - 但仅在几个小时后的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我使用 Strava 作为我的外部登录提供程序(我假设这与 Strava 无关,也可能是 google 或 facebook)运行几个小时/天甚至几周后 GetExternalLoginInfoAsync 返回 null.我已经阅读了许多具有相同问题的其他问题,但没有找到解决方案.我发布了我的整个 ConfigureAuth 方法,以防我对订单做错了什么.

I'm using Strava as my external login provider (I assume this is not related to Strava, could be google or facebook also) After running for a few hours / days or even weeks GetExternalLoginInfoAsync return null. I've read a bunch of other questions with the same problem, but did not find a solution. I post my entire ConfigureAuth method, just in case I did something wrong with the order.

如果您有一个 strava 帐户,您可能会在这里遇到问题:fartslek.no/Account/Login

If you have a strava account you could probably experience the problem here: 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", }); }

我正在使用这个 github/Johnny2Shoes/Owin.Security.Strava 获取 StravaAuth.

I'm using this github/Johnny2Shoes/Owin.Security.Strava to get StravaAuth.

当它停止工作时,天蓝色重置是不够的,但如果我进行新的部署,一切都会工作一段时间.

When it stop working a azure reset is not enough, but if I do a new deploy everything works for a while.

我正在使用 Owin 3.0.1 和 Mvc 5.2.3

I'm using Owin 3.0.1 and Mvc 5.2.3

推荐答案

我也遇到了同样的问题.谷歌搜索了一下,我发现这是 Owin 中的一个已知错误,因为它们处理 cookie 的方式.

I had the same problem. After googling a little, I've discovered this is a known bug in Owin, because of the way they handle cookies.

此问题已提交给 Katana 团队,但看起来他们不会在全部.有很多解决方法,但这是我能找到的最简单的:

This issue was submitted to Katana Team, but it looks they won't fix it at all. There are many workarounds for this, but this was the simplest I could find:

[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 })); }

请参阅此 询问有关此错误的更多详细信息,并让我知道这是否适合您.

See this question for more details about this bug, and let me know if this works well for you.

更多推荐

GetExternalLoginInfoAsync() loginInfo 返回 null

本文发布于:2023-11-16 18:36:41,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1606799.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:GetExternalLoginInfoAsync   loginInfo   null

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!