Dzmitry
Dzmitry

Reputation: 749

Login to gmail account

I need to be able to login to my gmail account, then i get cookies and will have access to other google services. But i can't login to my gmail(or any goolgle) account. I found some posts on this site how to do it, but none works for me. i do :

        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();
        }

Response return : "Your browser's cookie functionality is turned off. Please turn it on." I also tried make req.Headers.Add(HttpRequestHeader.CacheControl, "no-cache=set-cookie"); but it was unseccussfull too.

Does anybody know where is a problem ?

Upvotes: 2

Views: 74755

Answers (1)

MrWhite
MrWhite

Reputation: 45829

"Your browser's cookie functionality is turned off. Please turn it on."

You will probably need to have 3rd party cookies enabled in your browser. These are off by default in some browsers. You get the same warning in Firefox when using the Gmail Manager plugin if you disable 3rd party cookies.

Upvotes: 0

Related Questions