public async Task <ActionResult <GetDictReply> > TestCallRpcService() { var jwtToken = await _contextAccessor.HttpContext.GetTokenAsync("access_token"); if (jwtToken == null) { var authRpcResult = await _authRpcServcie.Login(new LoginRequest { Account = "alpha2008", Password = "******" }); if (authRpcResult.IsSuccessStatusCode) { jwtToken = authRpcResult.Content.Token; } return(NotFound()); } var dictRpcResult = await _maintRpcServcie.GetDict($"Bearer {jwtToken}", 29); if (dictRpcResult.IsSuccessStatusCode) { return(dictRpcResult.Content); } var apiError = ((Refit.ValidationApiException)dictRpcResult.Error).Content; return(Problem(apiError.Detail, dictRpcResult.Error.Uri.ToString(), apiError.Status, apiError.Title, apiError.Type)); }
public async Task <LoginReply> Login([FromBody] LoginRequest loginRequest) { var result = await _authRpcService.Login(loginRequest); return(result); //var result = await RestService.For<IAuthRpcService>("http://localhost:5010").Login(loginRequest); //return result; }
public async Task <IActionResult> Login([FromBody] LoginRequest loginRequest) { var result = await _authRpcService.Login(loginRequest); if (result.IsSuccessStatusCode) { return(Ok(result.Content)); } var apiError = ((Refit.ValidationApiException)result.Error).Content; return(Problem(apiError.Detail, result.Error.Uri.ToString(), apiError.Status, apiError.Title, apiError.Type)); }
public async Task <IActionResult> Login([FromBody] LoginRequest loginRequest) { var result = await _authRpcService.Login(loginRequest); if (result.IsSuccessStatusCode) { return(new OkObjectResult(result.Content)); } return(new JsonResult(result.Error.Content) { StatusCode = (int)result.StatusCode }); }
public async Task <GetDictReply> TestCallRpcService() { GetDictReply result; var jwtToken = await _contextAccessor.HttpContext.GetTokenAsync("access_token"); try { if (jwtToken == null) { var rpcResult = await _authRpcServcie.Login(new LoginRequest { Account = "alpha2008", Password = "******" }); jwtToken = rpcResult.Content.Token; } result = await _maintRpcServcie.GetDict($"Bearer {jwtToken}", 29); } catch (Exception ex) { throw ex; } return(result); }