I'm using .net. 4.5.2 and latest version on Identity in my application. There are cases I get strange error from external login ".AspNet.Correlation.Google cookie not found."
In the logs I see the the I see the url "/signin-google?state=STATE FROM GOOGLE (I got it)" but "AuthenticationManager.GetExternalLoginInfoAsync" returns NULL and my logs showing the error I mentioned. This is my configurations:
var cookieOptions = new CookieAuthenticationOptions
{
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
LoginPath = new PathString("/Account/Login"),
CookieName = ".myApp",
CookieDomain = ".myApp.com"
CookieHttpOnly = true,
SlidingExpiration = false,
Provider = new CookieAuthenticationProvider
{
OnResponseSignOut = (context) =>
{
//remove user cache
},
OnResponseSignIn = context =>
{
//add token to claims
},
OnException = (context) =>
{
//prevent exception display
},
OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<UserManager, User, int>(
validateInterval: TimeSpan.FromMinutes(IdentityExpiresIn),
regenerateIdentityCallback: (manager, user) =>
{
var identity = manager.CreateIdentityAsync(user,
DefaultAuthenticationTypes.ApplicationCookie);
return identity;
},
getUserIdCallback: (id) => (id.GetUserId<int>()))
}
};
app.UseCookieAuthentication(cookieOptions);
app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);
var googleOAuth2AuthenticationOptions = new GoogleOAuth2AuthenticationOptions()
{
ClientId = AppSettings.Get<string>("GoogleAppID"),
ClientSecret = AppSettings.Get<string>("GoogleAppSecret"),
SignInAsAuthenticationType = DefaultAuthenticationTypes.ExternalCookie,
};
googleOAuth2AuthenticationOptions.Scope.Add("email,profile");
app.UseGoogleAuthentication(googleOAuth2AuthenticationOptions);
The issue happens usually when using mobile devices and Chrome (cookies are supported) and also with Facebook connect