Ejemplo n.º 1
0
        private void button9_Click(object sender, EventArgs e)
        {
            if (!login == true)
            {
                string labase = null;
                if (File.Exists(appdatafile))
                {
                    if (Directory.Exists(File.ReadAllText(appdatafile)))
                    {
                        labase = File.ReadAllText(appdatafile);
                    }
                }

                if (String.IsNullOrEmpty(labase))
                {
                    labase = @"c:\launcher\";
                }

                textBox1.Text = labase;
            }
            else
            {
                Request authRequest = new Request(Request.Method.POST, URL.AUTHENTICATION.SIGN_IN);
                String  rawResponse = authRequest.Execute((string)Header.Authentication.Signin(textBox1.Text, textBox2.Text));
                AuthenticationResponse authResponse = new AuthenticationResponse(rawResponse);


                if (authResponse.GetResponse.Error == null)
                {
                    checkBox1.Hide();
                    MessageBox.Show("Bonjour " + authResponse.GetResponse.PlayerName);
                    //              Console.WriteLine("  AccessToken:" +  authResponse.GetResponse.AccessToken);
                    //              Console.WriteLine("  ClientToken: "+  authResponse.GetResponse.ClientToken);
                    button9.Hide();

                    label2.Hide();
                    textBox1.Hide();
                    textBox2.Hide();
                    checkBox1.Hide();
                    label3.Hide();
                    if (File.Exists(follow))
                    {
                        File.Delete(follow);
                    }


                    if (checkBox1.Checked == true)
                    {
                        MessageBox.Show("textbox coché");
                        // chekbox egal à true
                        //  + "username=@" + authResponse.GetResponse.PlayerName + "@"
                        File.WriteAllText(follow, "true");
                    }
                    else
                    {
                        MessageBox.Show("checkbox pas coché");
                        File.WriteAllText(follow, "false");
                    }

                    // écriture du account.json



                    client = "{\"accounts\":[{ \"accessToken\":\" " + "eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIwMzkyOTgxMTgxMWFiZTJhODRjOWEwZWQwNzNiMTY5YyIsInlnZ3QiOiJlNDI4OWY3MmQ3N2Y0ZTI0YWVkMzc3Y2I1NjA1ZjI1NiIsInNwciI6IjNjMjI5OTk5NDg2OTQ0ZDY4YjY4MmU1NDczNmEwZGRmIiwiaXNzIjoiWWdnZHJhc2lsLUF1dGgiLCJleHAiOjE2MTQ1MTczNzUsImlhdCI6MTYxNDM0NDU3NX0.TJmzaPF70bul0nTAal6Bj6a_soB1oT0bHnFoTF9rSOk" + "\",\"activeProfiles\":\"3c229999486944d68b682e54736a0ddf\", \"clientToken\":\"" + authResponse.GetResponse.ClientToken + "\",\"profiles\":[{\"id\":\"3c229999486944d68b682e54736a0ddf\",\"legacy\": false,\"name\":\"" + authResponse.GetResponse.PlayerName + "\"}],\"user\":{\"id\":\"03929811811abe2a84c9a0ed073b169c\"}, \"username\":\"" + textBox1.Text + "\"}],\"activeAccount\":\"" + textBox1.Text + "\",\"formatVersion\": 2}";
                    Console.WriteLine(authResponse.GetResponse.AccessToken);
                    Console.WriteLine(authResponse.GetResponse.ClientToken);
                    Console.WriteLine(authResponse.GetResponse.PlayerName);


                    File.WriteAllText(@"C:\Users\Maxime\Desktop\MultiMC\accounts.json", client);
                }
                else
                {
                    MessageBox.Show("Authentication failed.");
                    Console.WriteLine("PlayerName: " + authResponse.GetResponse.PlayerName);
                    Console.WriteLine("  ErrorType: " + authResponse.GetResponse.Error);
                    Console.WriteLine("  ErrorMessage: " + authResponse.GetResponse.ErrorMessage);
                }
            }
        }
Ejemplo n.º 2
0
        private void button9_Click(object sender, EventArgs e)
        {
            if (!login == true)
            {
                string labase = null;
                if (File.Exists(appdatafile))
                {
                    if (Directory.Exists(File.ReadAllText(appdatafile)))
                    {
                        labase = File.ReadAllText(appdatafile);
                    }
                }

                if (String.IsNullOrEmpty(labase))
                {
                    labase = @"c:\launcher\";
                }

                textBox1.Text = labase;
            }
            else
            {
                Request authRequest = new Request(Request.Method.POST, URL.AUTHENTICATION.SIGN_IN);
                String  rawResponse = authRequest.Execute((string)Header.Authentication.Signin(textBox1.Text, textBox2.Text));
                AuthenticationResponse authResponse = new AuthenticationResponse(rawResponse);


                if (authResponse.GetResponse.Error == null)
                {
                    checkBox1.Hide();
                    MessageBox.Show("Hello " + authResponse.GetResponse.PlayerName);
                    //              Console.WriteLine("  AccessToken:" +  authResponse.GetResponse.AccessToken);
                    //              Console.WriteLine("  ClientToken: "+  authResponse.GetResponse.ClientToken);
                    button9.Hide();

                    label2.Hide();
                    textBox1.Hide();
                    textBox2.Hide();
                    checkBox1.Hide();
                    label3.Hide();
                    if (File.Exists(follow))
                    {
                        File.Delete(follow);
                    }


                    if (checkBox1.Checked == true)
                    {
                        File.WriteAllText(pwd, authResponse.GetResponse.PlayerName);
                        label5.Text = authResponse.GetResponse.PlayerName;
                        MessageBox.Show("Password Remember");
                        // chekbox egal à true
                        //  + "username=@" + authResponse.GetResponse.PlayerName + "@"
                        File.WriteAllText(follow, "true");
                    }
                    else
                    {
                        MessageBox.Show("Password not Remember");
                        if (File.Exists(follow))
                        {
                            File.WriteAllText(follow, "false");
                        }
                    }

                    // écriture du account.json



                    client = "{\"accounts\":[{ \"accessToken\":\" " + authResponse.GetResponse.AccessToken + "\",\"activeProfiles\":\"3c229999486944d68b682e54736a0ddf\", \"clientToken\":\"" + authResponse.GetResponse.ClientToken + "\",\"profiles\":[{\"id\":\"3c229999486944d68b682e54736a0ddf\",\"legacy\": false,\"name\":\"" + authResponse.GetResponse.PlayerName + "\"}],\"user\":{\"id\":\"03929811811abe2a84c9a0ed073b169c\"}, \"username\":\"" + textBox1.Text + "\"}],\"activeAccount\":\"" + textBox1.Text + "\",\"formatVersion\": 2}";
                    Console.WriteLine(authResponse.GetResponse.AccessToken);
                    Console.WriteLine(authResponse.GetResponse.ClientToken);
                    Console.WriteLine(authResponse.GetResponse.PlayerName);
                    string labase = null;
                    if (File.Exists(appdatafile))
                    {
                        labase = File.ReadAllText(appdatafile);
                    }
                    // si "labase"  est null alors il set le dossier des fichiers à c:\launcher\

                    if (String.IsNullOrEmpty(labase))
                    {
                        labase = @"c:\launcher\";
                    }

                    File.WriteAllText(labase + @"multimc\accounts.json", client);
                    File.WriteAllText(@"c:\Temp\account.dll", authResponse.GetResponse.PlayerName);
                    button5.Show();
                    button7.Show();
                }
                else
                {
                    MessageBox.Show("Authentication failed.");
                    Console.WriteLine("PlayerName: " + authResponse.GetResponse.PlayerName);
                    Console.WriteLine("  ErrorType: " + authResponse.GetResponse.Error);
                    Console.WriteLine("  ErrorMessage: " + authResponse.GetResponse.ErrorMessage);
                }
            }
        }