protected override async Task <AuthenticationTicket> AuthenticateCoreAsync() { if (Options.CallbackPath.HasValue && Options.CallbackPath != (Request.PathBase + Request.Path)) { return(null); } var code = Request.Query["code"]; if (code == null) { var error = Request.Query["error"]; var error_description = Request.Query["error_description"]; _logger?.LogError("No auth code detected in SSO response. Error: {error}, Description: {error_description}", error, error_description); } _logger?.LogDebug("Received an authorization code from IDP: " + code); _logger?.LogInformation("== exchanging auth code for token =="); var exchanger = new TokenExchanger(Options.AsAuthServerOptions(HostInfoFromRequest(Request) + Options.CallbackPath), null, _logger); var identity = await exchanger.ExchangeAuthCodeForClaimsIdentity(code).ConfigureAwait(false); var properties = Options.StateDataFormat.Unprotect(Request.Query["state"]); return(new AuthenticationTicket(identity, properties)); }
protected override async Task <AuthenticationTicket> AuthenticateCoreAsync() { var code = Request.Query["code"]; Debug.WriteLine("Received an authorization code from IDP: " + code); Debug.WriteLine("== exchanging for token =="); // ASP.Net Identity requires the NameIdentitifer field to be set or it won't // accept the external login (AuthenticationManagerExtensions.GetExternalLoginInfo) var identity = await TokenExchanger.ExchangeCodeForToken(code, Options); var properties = Options.StateDataFormat.Unprotect(Request.Query["state"]); // return Task.FromResult(new AuthenticationTicket(identity, properties)); var ticket = new AuthenticationTicket(identity, properties); return(ticket); }