public async Task <ActionResult> ExternalLoginAsync([FromForm] ExternalLoginRequest model) { // describe real logic here //var user = await _userManager.FindByEmailAsync(model.Email); var user = new { Id = Guid.NewGuid(), LastName = "Less", FirstName = "Steve", EmailConfirmed = true, }; if (user == null) { return(BadRequest("User not found.!")); } if (!user.EmailConfirmed) { return(BadRequest("User should confirm his email.")); } // describe real logic here //var result = await _signInManager.PasswordSignInAsync(model.Email, model.Password, false, lockoutOnFailure: true); var result = new { Succeeded = true, }; if (result.Succeeded) { List <KeyValuePair <object, object> > keyValueList = new List <KeyValuePair <object, object> > { new KeyValuePair <object, object>(ClaimTypes.Email, model.Email), new KeyValuePair <object, object>(ClaimTypes.NameIdentifier, user.Id), }; var accessToken = _tokenProvider.CreateAccessToken(keyValueList, _jwtTokenOptions.Value.LifetimeExternal); var redirectUrl = model.RedirectUri + "#state=" + HttpUtility.UrlEncode(model.State) + "&access_token=" + HttpUtility.UrlEncode(accessToken.AccessToken) + "&token_type=Bearer"; return(new RedirectResult(redirectUrl)); } return(BadRequest()); }