2014-12-21 2 views
0

Gmail 계정에 로그인하고 100 번 암호를 변경하여 이전 암호로 설정하려고합니다. (아시다시피 Google은 100 개의 이전 비밀번호 기록을 보관하며 그 중 하나를 선택하도록 허용하지 않습니다.) HttpWebRequest 및 HttpWebResponse를 사용하여 문제를 해결하고 있습니다. 나는 Fiddler에서 요청과 응답을 모니터링했다. 그러나 다음 코드로 Gmail에 로그인 할 때 쿠키가 없습니다. 문제가 어디입니까?!HttpWebRequest를 사용하여 Gmail에 로그인했습니다. 쿠키가 수신되지 않았습니다.

  HttpWebRequest http = WebRequest.Create("https://accounts.google.com/ServiceLoginAuth") as HttpWebRequest; 
     http.KeepAlive = true; 
     http.Host = "accounts.google.com"; 
     http.CachePolicy = new HttpRequestCachePolicy(HttpCacheAgeControl.MaxAge, new TimeSpan(0)); 
     http.Referer = "https://accounts.google.com/ServiceLogin?sacu=1&scc=1&continue=https%3A%2F%2Fmail.google.com%2Fmail%2F&hl=en&service=mail"; 
     http.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8"; 
     http.UserAgent = "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36"; 
     http.Method = "POST"; 
     http.ContentType = "application/x-www-form-urlencoded"; 
     string postData = ""; 
     postData += "GALX=" + "qpld0kUdZuc"; 
     postData += "&continue=" + "https://mail.google.com/mail/"; 
     postData += "&service=" + "mail"; 
     postData += "&rm=" + "false"; 
     postData += "&itmpl=" + "default"; 
     postData += "&hl=" + "en"; 
     postData += "&scc=" + "1"; 
     postData += "ss=" + "1"; 
     postData += "&sacu=" + "1"; 
     postData += "&_utf8=" + "☃"; 
     postData += "&bgresponse=" + "!A0L90r-qE6ZLyUQ7tYD_B09KGgIAAAAjUgAAAAcqARcN5-HZ6OMO9yMKHpX_wJvfu81b67CyiAbn0EbvzuV9yjTly_ZM6err6uAruVCVnx5qUodg7vq6PIaYWpBtVnOzc2Ean-7ITFxt4SqBb0VAKLOJElXwWmximH-oydxBVH05VR4xLmWF1D00_yiPaXcqibx8ihD8yB1e8bOWrmfdzuVgyOfImv1LTSATv-AMI2W0dfTJlWmmngo4yefWiIEAYHJwixpArol4gDtxBAW81W98CMyXPNxXyu3JV3mCUMSrCh1EPJAX3DpfrU7bmD1O-gO7p8Gw5qU1vAuYt61AaLC9ydABYpvd3oysvccseXDdXJEI9fpeoOV8TNc3QvLYarUPbtjG1gYxgMh_zY72ogVucxCoj8U"; 
     postData += "&pstMsg=" + "1"; 
     postData += "&dnConn=" + ""; 
     postData += "&checkConnection=" + ""; 
     postData += "&checkedDomains=" + "youtube"; 
     postData += "&Email=" + "myEmailAddress"; 
     postData += "&Passwd=" + "my password"; 
     postData += "&signIn=" + "Sign in"; 
     postData += "&PersistentCookie=" + "yes"; 
     byte[] dataBytes = UTF8Encoding.UTF8.GetBytes(postData); 
     http.ContentLength = dataBytes.Length; 
     using (Stream postStream = http.GetRequestStream()) 
     { 
      postStream.Write(dataBytes, 0, dataBytes.Length); 
     } 
     HttpWebResponse httpResponse = http.GetResponse() as HttpWebResponse; 
     // Probably want to inspect the http.Headers here first 
     http = WebRequest.Create("https://accounts.google.com/b/0/EditPasswd") as HttpWebRequest; 
     http.CookieContainer = new CookieContainer(); 
     http.CookieContainer.Add(httpResponse.Cookies); 

답변