2
내가 구글 쿠키 인증을 사용하여 작동하지 않습니다ASP.NET 핵심 웹 응용 프로그램 ExpireTimeSpan은 다음과 같은 옵션이
구글 쿠키를 통해 인증 30 분 후에 만료됩니다 후 app.UseCookieAuthentication(new CookieAuthenticationOptions()
{
AuthenticationScheme = "MyCookieMiddlewareInstance",
LoginPath = new PathString("/Account/Login/"),
AccessDeniedPath = new PathString("/Account/Forbidden/"),
AutomaticAuthenticate = true,
AutomaticChallenge = true,
ExpireTimeSpan = TimeSpan.FromDays(14.0)
});
app.UseGoogleAuthentication(new GoogleOptions()
{
SignInScheme = "MyCookieMiddlewareInstance",
AutomaticAuthenticate = true,
ClientId = "xxx",
ClientSecret = "xxx"
}
[HttpPost]
[AllowAnonymous]
[ValidateAntiForgeryToken]
public IActionResult ExternalLogin(string provider, string returnUrl = null)
{
// Request a redirect to the external login provider.
var redirectUrl = Url.Action("ExternalLoginCallback", "Account", new { ReturnUrl = returnUrl });
var properties = _signInManager.ConfigureExternalAuthenticationProperties(provider, redirectUrl);
return Challenge(properties, provider);
}
[HttpGet]
[AllowAnonymous]
public IActionResult ExternalLoginCallback(string returnUrl = null, string remoteError = null)
{
return RedirectToLocal(returnUrl);
}
. 그리고 그들은 세션을 위해 만들어졌습니다.
나는 exparation 시간을 높이기 위해 무엇을해야합니까?
답장을 보내 주셔서 감사합니다. app.UseIdentity(); Startup.cs,하지만 이제는 _signInManager.GetExternalLoginInfoAsync();를 기다리고 있습니다. 항상 null이며 앱에서 승인되면 로그인 페이지로 리디렉션됩니다. 이 문제를 검색하려고했지만 해결책을 찾지 못했습니다. –
Startup.cs에서 app.UseCookieAuthentication을 설명하기 위해이 문제가 해결되었습니다. 이제는 _signInManager.ExternalLoginSignInAsync을 (를) 기다리는 데 예외가 있습니다. "이 DbContext에 대해 데이터베이스 공급자가 구성되어 있지 않습니다." 나는 서비스가있다 .AddDbContext(); 및 .AddEntityFrameworkStores (); 응용 프로그램이 없으면 작동하지 않기 때문에 시작할 수 없습니다. –
결국 app.UseIdentity()를 삭제했습니다. StartUp에서 추가하고 HttpContext.Authentication.SignInAsync ("MyCookieMiddlewareInstance", User, properties)를 기다립니다. 다음과 같이 ExternalLoginCallback에 : [http://i.imgur.com/fpLiiGS.png] (http://i.imgur.com/fpLiiGS.png) 그것은 나를 위해 작동합니다. –