public ActionResult Login(LoginModel loginModel) { TokenReciever token = GetToken(loginModel); Session["TokenKey"] = token.token_type + " " + token.access_token; return(RedirectToAction("HomeView", "VehicleRegister")); }
private TokenReciever GetToken(LoginModel loginModel) { TokenReciever RecievedToken = null; using (HttpClient client = new HttpClient()) { var stringContent = new StringContent(loginModel.GetTokenRequestString(), Encoding.UTF8, "application/x-www-form-urlencoded"); var response = client.PostAsync(endPoints.GetToken, stringContent).Result; if (response != null) { var jsonString = response.Content.ReadAsStringAsync().Result; RecievedToken = JsonConvert.DeserializeObject <TokenReciever>(jsonString); } } return(RecievedToken); }