Честно говоря, я понятия не имею, что я сделал не так, что URI не возвращает представление должным образом.
Вот моя конфигурация для Discord OAuth2 аутентификация:
Код: Выделить всё
[HttpGet("/signin-discord")]
public async Task ExternalLoginCallback()
{
var authenticateResult = await HttpContext.AuthenticateAsync("Discord");
if (!authenticateResult.Succeeded)
{
// Handle authentication failure
return RedirectToAction("Login", "Account"); // Redirect to login page or handle as needed
}
// Retrieve Discord user information
var userId = authenticateResult.Principal.FindFirst(ClaimTypes.NameIdentifier)?.Value;
var username = authenticateResult.Principal.FindFirst(ClaimTypes.Name)?.Value;
// Example: Authenticate user locally (store in session or database)
var claims = new[]
{
new Claim(ClaimTypes.NameIdentifier, userId),
new Claim(ClaimTypes.Name, username),
// Add additional claims as needed
};
var identity = new ClaimsIdentity(claims, "Discord");
var principal = new ClaimsPrincipal(identity);
// Sign in the user
await HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, principal);
// Redirect to your viewer page or any desired endpoint
return View("DrawingPad"); // This will render Views/Drawing/DrawingPad.cshtml
//return RedirectToAction("DrawingPad", "Drawing");
}
Код: Выделить всё
[HttpGet("/signin-discord")]
public async Task ExternalLoginCallback()
//return RedirectToAction("Index", "Home");}
Подробнее здесь: https://stackoverflow.com/questions/787 ... -500-error