I am trying to do a script that reads the names and then sends a login request but it is random, how do I do it from first to last? EDIT: I want it to read the name from a file, try to log in, and then move on to the next one
var lines6 = File.ReadAllLines(userspath);
var ro6 = new Random();
var randomLineNumber6 = ro6.Next(0, lines6.Length - 1);
var line6 = lines6[randomLineNumber6];
var client = new RestClient("https://eu.mspapis.com/loginidentity/connect/token");
var request = new RestRequest();
request.RequestFormat = DataFormat.Json;
var r = request.AddObject(new
{
client_id = "unity.client",
client_secret = "secret",
grant_type = "password",
scope = "openid nebula offline_access",
username = server + "|" + line6,
password = password,
acr_values = "GameId:j68d",
});
var response = client.Execute(r, Method.POST);
if (response.Content.Contains("access_token"))
{
Console.WriteLine("[ok]" + line6);
}
else
{
Console.WriteLine("[wrong] " + line6);
}
I'd recommend randomizing the array instead of picking random items in the array to guarantee never picking an item twice. There are a bunch of ways to do this, but something like
var ro6 = new Random()
foreach (var username in lines6.OrderBy(x => ro6.Next()))
{
//login
}
Should work, with all your login code where //login is. Then just put a break; statement when you successfully log in, or a return statement or something.
edit: if you don't need the randomness and I misunderstood the question, just get rid of the orderBy section
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.