Advertisement
Guest User

Untitled

a guest
Feb 25th, 2016
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.52 KB | None | 0 0
  1. using System;
  2. using System.IO;
  3. using System.Net;
  4. using System.Text;
  5. using System.Windows.Forms;
  6.  
  7. namespace Login
  8. {
  9. public partial class LoginForm : Form
  10. {
  11. public LoginForm()
  12. {
  13. InitializeComponent();
  14. }
  15.  
  16. private void loginButton_Click(object sender, EventArgs e)
  17. {
  18. string username = usernameTextBox.Text;
  19. string password = passwordTextBox.Text;
  20.  
  21. string postData = "scope=openid&client_id=36926892495301a63b2e9350a38d3d6dbf72ad81e571a3ebba4687250ec8f352c70b3e91229602f73e1335528f3caa00a5cf513f484d7003784e722f2ce7a216&redirect_uri=http%3A%2F%2Fwww.twitch.tv%2F&response_type=code&state=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJyZWRpcmVjdF9wYXRoIjoiaHR0cDovL3d3dy50d2l0Y2gudHYvIn0.bvJnmxyvmepBV4cxdGbNevMJj_ki4cTn0OxmJBy8Lkc&nonce=8f24aa00cd07af0f4ea4cac613566629aab5e1d1&from_embed=false&username=" + username + "&password=" + password;
  22. UTF8Encoding encoding = new UTF8Encoding();
  23. byte[] postValue = encoding.GetBytes(postData);
  24. HttpWebRequest postRequest = (HttpWebRequest)WebRequest.Create("https://passport.twitch.tv/authentications/new");
  25. postRequest.Method = WebRequestMethods.Http.Post;
  26. postRequest.ContentType = "application/x-www-form-urlencoded";
  27. postRequest.Referer = "https://passport.twitch.tv/authentications/new?client_id=36926892495301a63b2e9350a38d3d6dbf72ad81e571a3ebba4687250ec8f352c70b3e91229602f73e1335528f3caa00a5cf513f484d7003784e722f2ce7a216&embed=0&error_code=&nonce=8f24aa00cd07af0f4ea4cac613566629aab5e1d1&redirect_uri=http%3A%2F%2Fwww.twitch.tv%2F&response_type=code&scope=openid&state=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJyZWRpcmVjdF9wYXRoIjoiaHR0cDovL3d3dy50d2l0Y2gudHYvIn0.bvJnmxyvmepBV4cxdGbNevMJj_ki4cTn0OxmJBy8Lkc&stay_embedded=0&sudo_reason=&username=";
  28. postRequest.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.116 Safari/537.36";
  29. postRequest.ContentLength = postValue.Length;
  30.  
  31. using (Stream postRequestStream = postRequest.GetRequestStream())
  32. {
  33. postRequestStream.Write(postValue, 0, postValue.Length);
  34.  
  35. HttpWebResponse postResponse = (HttpWebResponse)postRequest.GetResponse();
  36. StreamReader postRequestReader = new StreamReader(postResponse.GetResponseStream());
  37. string document = postRequestReader.ReadToEnd();
  38.  
  39. twitchWebBrowser.DocumentText = document;
  40. }
  41. }
  42. }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement