Ich habe ein seltsames Problem mit der Protokollierung mit OWIN OAUTH in meiner Testumgebung. Ich erstelle ein Konto von meinem PC im Büro mit Google und ich kann nicht dasselbe Google-Konto verwenden, um mich von zu Hause oder meinem Mobiltelefon anzumelden. Das passiert auch mit Facebook.ASP.NET MVC OWIN OAUTH Login wird nicht von verschiedenen Rechner
Setup:.
public partial class Startup
{
public void ConfigureAuth(IAppBuilder app)
{
/* Local login implementation */
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
LoginPath = new PathString("/login"),
ExpireTimeSpan = TimeSpan.FromDays(3),
});
app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);
/* Login with Google */
var googleOptions = new GoogleOAuth2AuthenticationOptions
{
ClientId = "",
ClientSecret = "",
};
googleOptions.Scope.Add("https://www.googleapis.com/auth/userinfo.profile");
googleOptions.Scope.Add("https://www.googleapis.com/auth/userinfo.email");
app.UseGoogleAuthentication(googleOptions);
AntiForgeryConfig.UniqueClaimTypeIdentifier = ClaimTypes.NameIdentifier;
}
}
Oauth-Controller
public class oauthcontroller : basecontroller
{
private readonly IUserService _userService;
// Google login button click
public ActionResult google()
{
return new ChallengeResult(LoginProviderEnum.Google.DisplayName, "/oauth/callback");
}
public ActionResult callback()
{
// context is not null
var context = HttpContext.GetOwinContext();
// auth is null
var auth = context.Authentication;
var loginInfo = auth.GetExternalLoginInfo();
//...
}
}
Wenn bei der Arbeit meinen PC das funktioniert gut und wenn sie von verschiedenen Maschinen Anmeldung HttpContext.GetOwinContext() Authentifizierung ist null .
UPDATE: schaffte ich es in localhost ASP.NET_SessionId durch Entfernen Cookie zu reproduzieren ist