static void GenerateTokens(string API_Secret) { string Request_Token, Public_Token, Access_Token; Console.WriteLine("Please enter the request_token:"); Request_Token = Console.ReadLine(); KC.User user = kc.GenerateSession(Request_Token, API_Secret); Public_Token = user.PublicToken; Access_Token = user.AccessToken; WriteToCache("public_token", Public_Token, DateTime.Parse("11:30 PM")); WriteToCache("access_token", Access_Token, DateTime.Parse("11:30 PM")); }
public async Task <ActionResult> Index(LoginViewmodel model) { if (ModelState.IsValid) { kite = new KiteConnect.Kite(APIKey: model.ApiKey, Debug: true); User user = kite.GenerateSession(model.RequestToken, model.ApiSecret); var userSessionModel = new UserSessionModel() { AccessToken = user.AccessToken, ApiKey = model.ApiKey, AppSecret = model.ApiSecret, UserId = model.ZerodhaUserId, PublicToken = user.PublicToken }; await _userSessionService.SetCurrentSession(userSessionModel); Session["userSession"] = userSessionModel; return(RedirectToAction("Index", "Home")); } ModelState.AddModelError("Something went wrong", "please contact admin"); return(View(model)); }