public async Task <IActionResult> GetCredentialByName(string credentialName) { try { if (!HttpContext.Request.IsHttps)//if request is not https, then throw unauthorized exception { throw new UnauthorizedAccessException("Request must be HTTPS"); } return(Ok(_credentialManager.GetMatchingCredential(credentialName))); } catch (Exception ex) { return(ex.GetActionResult()); } }