gpt4 book ai didi

asp.net - GetExternalLoginInfoAsync() loginInfo 返回 null - 但仅在几个小时后

转载 作者:行者123 更新时间:2023-12-02 10:25:55 25 4
gpt4 key购买 nike

我使用 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 Team,但看起来他们根本不会修复它。有很多解决方法,但这是我能找到的最简单的方法:

    [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 - GetExternalLoginInfoAsync() loginInfo 返回 null - 但仅在几个小时后,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36459051/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com