static bool authenticate(RobinhoodClient client) { if (System.IO.File.Exists(__tokenFile)) { var token = System.IO.File.ReadAllText(__tokenFile); if (!client.Authenticate(token)) { if (System.IO.File.Exists(__tokenFile)) { System.IO.File.Delete(__tokenFile); } return(false); } return(true); } else { Console.Write("username: "******"password: "); string password = getConsolePassword(); if (!client.Authenticate(userName, password)) { return(false); } System.IO.Directory.CreateDirectory( System.IO.Path.GetDirectoryName(__tokenFile)); System.IO.File.WriteAllText(__tokenFile, client.AuthToken); return(true); } }
public static async Task authenticate(RobinhoodClient client) { /// See if we need a new token file - either none exists or file is over X hours old bool shouldGetNewTokenFile = !System.IO.File.Exists(__tokenFile) || !IsTokenFileAgeLessThan(CONSTANTS.TOKEN_FILE_MAX_AGE_HOURS); if (shouldGetNewTokenFile) { await GenerateTokenFile().ConfigureAwait(continueOnCapturedContext: false); } ; //startApp(); /// Run a console app to create a token file /// If the file exists and it's less than X hours old if (System.IO.File.Exists(__tokenFile) && IsTokenFileAgeLessThan(CONSTANTS.TOKEN_FILE_MAX_AGE_HOURS)) { /// Read the access token from the token file var token = System.IO.File.ReadAllText(__tokenFile); /// Use the access token to authenticate await client.Authenticate(token); } }
public static async Task Login() { //Read login credentials StreamReader loginFile = File.OpenText("Login.login"); Username = loginFile.ReadLine(); Password = loginFile.ReadLine(); Client = new RobinhoodClient(); await Client.Authenticate(Username, Password); UpdateAccountInfo(); }
static async Task GenerateTokenFile() { //Console.Write("username: "); var rh = new RobinhoodClient(); await rh.Authenticate(CONSTANTS.USER_NAME, CONSTANTS.PASSWORD).ConfigureAwait(continueOnCapturedContext: false);; System.IO.Directory.CreateDirectory( System.IO.Path.GetDirectoryName(__tokenFile)); System.IO.File.WriteAllText(__tokenFile, rh.AuthToken); }
static async Task authenticate(RobinhoodClient client) { if (System.IO.File.Exists(__tokenFile)) { var token = System.IO.File.ReadAllText(__tokenFile); await Task.FromResult(client.Authenticate(token)); } else { Console.Write("username: "******"password: "); string password = getConsolePassword(); await Task.FromResult(client.Authenticate(userName, password)); System.IO.Directory.CreateDirectory( System.IO.Path.GetDirectoryName(__tokenFile)); System.IO.File.WriteAllText(__tokenFile, client.AuthToken); } }
static async Task authenticate(RobinhoodClient client, string userName, string pwd) { if (System.IO.File.Exists(__tokenFile)) { var token = System.IO.File.ReadAllText(__tokenFile); await client.Authenticate(token); } else { //Console.Write("username: "******"jamiator21"; //Console.ReadLine(); //Console.WriteLine("username: jamiator21"); // Console.Write("password: "******"Complicated12";// getConsolePassword(); await client.Authenticate(userName, pwd); System.IO.Directory.CreateDirectory( System.IO.Path.GetDirectoryName(__tokenFile)); System.IO.File.WriteAllText(__tokenFile, client.AuthToken); } }
/// <summary> /// Logs in to an account /// </summary> /// <param name="username">The account username (email address)</param> /// <param name="password">The account password</param> public void SignIn(string username, string password) { this.UserName = username; Client.Authenticate(username, password); }
static async Task authenticate (RobinhoodClient client) { if (System.IO.File.Exists(__tokenFile)) { var token = System.IO.File.ReadAllText(__tokenFile); await client.Authenticate(token); } else { Console.Write("username: "******"password: "); string password = getConsolePassword(); await client.Authenticate(userName, password); System.IO.Directory.CreateDirectory( System.IO.Path.GetDirectoryName(__tokenFile)); System.IO.File.WriteAllText(__tokenFile, client.AuthToken); } }
/// <summary> /// Logs in to an account /// </summary> /// <param name="username">The account username (email address)</param> /// <param name="password">The account password</param> public (bool, ChallengeInfo) SignIn(string username, string password, string deviceToken, string challengeID) { this.UserName = username; return(Client.Authenticate(username, password, deviceToken, challengeID)); }