I want to add Google Authentication to Cookie Authentication with this config: StartUp:
//ConfigureServices: services.AddAuthentication( ) .AddCookie(CookieAuthenticationDefaults.AuthenticationScheme, options => { // ... }) .AddGoogle(options => { IConfigurationSection googleAuthNSection = Configuration.GetSection("ExternalLogin:Google"); options.ClientId = googleAuthNSection["ClientId"]; options.ClientSecret = googleAuthNSection["ClientSecret"]; options.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme; options.CorrelationCookie.SameSite = SameSiteMode.Lax; }); //Configure(): app.UseAuthentication(); app.UseAuthorization();
and
[AllowAnonymous] public IActionResult SigninGoogle(string returnurl) { var authProperties = new AuthenticationProperties { RedirectUri = Url.Action("ExternalLoginCallback","Auth",new{returnurl}).ToString(), Items = { { "LoginProvider", "Google" }, }, AllowRefresh = true, }; return Challenge(authProperties, GoogleDefaults.AuthenticationScheme ); } [AllowAnonymous][HttpGet("signin-google")] public async Task<IActionResult> ExternalLoginCallback(string returnurl, string remoteError = null) { var result = await HttpContext.AuthenticateAsync(CookieAuthenticationDefaults.AuthenticationScheme); if (result.Succeeded) {} //.. }
after click "SigninGoogle" and login in to google it is ok!
but in back google to "signin-google" i have problem:
https://stackoverflow.com/questions/66744435/google-authentication-correlation-failed-unknown-location March 22, 2021 at 06:39PM
没有评论:
发表评论