public static async Task <AuthenticationResponse> AuthenticateUser(string username, string password, string domain, string app) { AuthenticationRequest authRequest = AuthenticationRequest.FromUsernamePasswordDomainAndApp(username, password, domain, app); try { AuthenticationResponse authResponse = await APIs.AuthenticateUserUrl.PostJsonAsync(authRequest).ReceiveJson <AuthenticationResponse>(); var authJson = Newtonsoft.Json.JsonConvert.SerializeObject(authResponse, Newtonsoft.Json.Formatting.Indented); return(authResponse); } catch (FlurlHttpException exc) { var errorDetail = await exc.GetResponseJsonAsync <ProblemDetailResponse <AuthenticationProblem> >(); var authErrorJson = Newtonsoft.Json.JsonConvert.SerializeObject(errorDetail, Newtonsoft.Json.Formatting.Indented); AuthenticationResponse errorResponse = new AuthenticationResponse ( responseId: errorDetail.ProblemDetailId, correlationId: errorDetail.CorrelationId, isAuthenticated: errorDetail.CustomProblem.IsAuthenticated, jwt: errorDetail.CustomProblem.Jwt, responseCode: errorDetail.CustomProblem.ErrorCode, responseMessage: errorDetail.Detail, customDataJson: errorDetail.CustomProblem.CustomDataJson ); return(errorResponse); } }