title: Authenticating users with IdentityServer4 without a Login page
body: <p>We built a Xamarin.Forms app that operates as an IdentityServer4 client using the WebView implementation approach, which worked perfectly. However, Apple will not accept our app in the store because they want the authentication and new account creation to occur within the app. Therefore, I've been trying to post the credentials entered within the app's login screen to the IdentityServer with the hope that I can simulate the same process that occurs when a user enters their credentials and submits (posts) the login page:</p>
  
  <pre><code> public async Task&lt;IActionResult&gt; Authenticate([FromBody] UserLoginViewModel model)
      {
          String result = String.Empty;
  
          try
          {
              if (!string.IsNullOrWhiteSpace(model.UserName))
              {
                  UserKey user = await _userManager.FindByNameAsync(model.UserName.ToLowerInvariant());
  
                  if (String.IsNullOrEmpty(user?.SSID))
                  { result = AuthenticateResultEnum.UserDoesNotExist.ToString(); }
                  else
                  {
                      var signin_result = await _signInManager.PasswordSignInAsync(user, model.Password, model.RememberLogin, false);
                      if (signin_result.Succeeded)
                      {
                          if (_interactionService.IsValidReturnUrl(model.ReturnUrl))
                          {
                              LocalRedirect(model.ReturnUrl);
                          }
                      }
                      else if (signin_result.IsLockedOut)
                      { result = AuthenticateResultEnum.AccountLocked.ToString(); }
                  }
              }
          }
          catch (Exception ex)
          {
              result = AuthenticateResultEnum.Error.ToString();
              _logger.ExceptionAsync(ex);
          }
  
          return new JsonResult(result);
      }
  </code></pre>
  
  <p>However, I've had no luck with this process because of all the redirects involved. Is there a well-established way of authenticating a user with IdentityServer without showing a login page, but instead posting the credentials and Authorization Request from the apps login form? Other well-known apps appear to be able to do so, I'm just seeking confirmation that it can be done with IdentityServer4.</p>
  
  <p>Thank you,
  Andrew</p>