我使用Strava作爲我的外部登錄提供程序(我認爲這與Strava無關,可能是谷歌或Facebook)運行幾個小時/幾天甚至幾周GetExternalLoginInfoAsync返回null。我讀過一系列其他問題,但沒有找到解決方案。我發佈了我的整個ConfigureAuth方法,以防萬一我的訂單出錯了。GetExternalLoginInfoAsync()loginInfo返回null - 但僅在幾個小時後
如果你有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
我想知道如果代碼在磁盤上的某處緩存壞auth數據。當您重新部署您的站點時,磁盤上的所有文件都將被刪除並替換爲新的文件,這可以解釋爲什麼之後認證開始起作用,而僅僅重置網站並不會執行任何操作。 –
有趣的理論。任何想法要檢查什麼? – Larsi
@ZainRizvi感謝您關注此事。這是一個普通的mvc站點,默認實現了身份驗證,我所做的唯一修改是將Strava作爲外部身份驗證提供程序添加。如果你能幫我弄清楚問題是什麼,我會非常高興。再次感謝您的時間 – Larsi