I have A simple login which have a default login and gmail login.
I have create one service on console google for setting redirect uri of my localhost when login gmail is used from application
my problem is why i always get Error 400: redirect_uri_mismatch, instead i have setting all environment client_id and client_secret in my project
may be somebody can help me
Thanks
public IActionResult ExternalLogin(string provider, string? returnUrl = null)
{
return new ChallengeResult(
GoogleDefaults.AuthenticationScheme,
new AuthenticationProperties
{
RedirectUri = Url.Action(nameof(LoginCallback),"Account", new { returnUrl })
});
}
public async Task<IActionResult> LoginCallback(string returnUrl)
{
var authenticateResult = await HttpContext.AuthenticateAsync("External");
if (!authenticateResult.Succeeded)
return BadRequest(); // TODO: Handle this better.
var claimsIdentity = new ClaimsIdentity("Application");
claimsIdentity.AddClaim(authenticateResult.Principal.FindFirst(ClaimTypes.NameIdentifier));
claimsIdentity.AddClaim(authenticateResult.Principal.FindFirst(ClaimTypes.Email));
await HttpContext.SignInAsync(
"Application",
new ClaimsPrincipal(claimsIdentity));
return LocalRedirect(returnUrl);
}
appsettings.json

program.cs

console google
