2010-07-22 5 views
0

내 Gmail 계정에 로그인 할 수 있어야 쿠키가 생기고 다른 Google 서비스에 액세스 할 수 있습니다. 하지만 내 Gmail (또는 모든 goolgle) 계정에 로그인 할 수 없습니다. 이 사이트에서 일부 게시물을 찾았지만 아무 것도 작동하지 않습니다. 할 :Gmail 계정에 로그인

 string formUrl = "https://www.google.com/accounts/ServiceLoginAuth"; 
     string formParams = string.Format("Email={0}&Passwd={1}&signIn={2}&PersistentCookie={3}&GALX={4}", 
      "autokuzov.top", "1QAZ2wsx", "Sign in", "yes", "CfFosrEhu-0"); 

     string cookieHeader; 
     HttpWebRequest req = (HttpWebRequest)WebRequest.Create(formUrl); 
     req.ContentType = "application/x-www-form-urlencoded"; 
     req.Referer = "https://www.google.com/accounts/ServiceLoginAuth"; 
     req.Method = "POST"; 

     req.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; ru; rv:1.9.2.7) Gecko/20100713 Firefox/3.6.7"; 
     req.AllowAutoRedirect = false; 

     req.CookieContainer = new CookieContainer(); 
     req.Headers.Add(HttpRequestHeader.CacheControl, "no-cache=set-cookie"); 

     byte[] bytes = Encoding.ASCII.GetBytes(formParams); 
     req.ContentLength = bytes.Length; 
     using (Stream os = req.GetRequestStream()) 
     { 
      os.Write(bytes, 0, bytes.Length); 
     } 
     WebResponse resp = req.GetResponse(); 

     using (StreamReader sr = new StreamReader(resp.GetResponseStream())) 
     { 
      string s = sr.ReadToEnd(); 
     } 

응답 반환 : "브라우저의 쿠키 기능이 꺼져 있습니다. 켜십시오." 나는 또한 req.Headers.Add (HttpRequestHeader.CacheControl, "no-cache = set-cookie"); 그러나 그것은 또한 unseccussfull이었다.

누구에게 문제가 있는지 알고 있습니까?

답변

0

"브라우저의 쿠키 기능 이 꺼져 있습니다. 켜십시오."

브라우저에서 타사 쿠키를 사용하도록 설정해야 할 수 있습니다. 일부 브라우저에서는 기본적으로 해제되어 있습니다. 타사 쿠키를 비활성화 한 경우 Gmail 관리자 플러그인을 사용할 때 Firefox에서 동일한 경고가 표시됩니다.

+0

내 Google 계정에 요청할 때 C#에서 타사 쿠키를 어떻게 활성화 할 수 있습니까? – Dzmitry

+0

브라우저 내에서 웹 서버에서이 작업을 실행하는 것은 불가능합니다. 보안상의 이유로 사용자 만이 작업을 수동으로 수행 할 수 있습니다. 외부 응용 프로그램으로 실행하는 경우 다음과 같습니다. – MrWhite

관련 문제