Using cookies for auth |
[Jan. 24th, 2006|02:53 pm]
LiveJournal Client Discussions
|
Now that LJ has completely changed its cookie handling procedure, does anybody have a clue how to use them to communicate with the server?
My old code, in C# .NET did the following to communicate with the server:
HttpWebRequest Create(string url, string ljsession, string uagent) { Uri uri = new Uri(url); HttpWebRequest wr = (HttpWebRequest) WebRequest.Create(uri.AbsoluteUri); wr.Method = "POST"; wr.ContentType = "application/x-www-form-urlencoded"; wr.ProtocolVersion = new Version(1, 0); wr.UserAgent = uagent; if (ljsession != null && ljsession.Length > 0) { wr.CookieContainer = new CookieContainer(); wr.CookieContainer.Add(new Cookie("ljsession", ljsession, "/", uri.Host)); wr.Headers.Add("X-LJ-Auth", "cookie"); } return wr; }
In a nutshell, I'm creating an C# object that handles all the HTTP layer communications, and passing it the value of the ljsession cookie obtained by the challenge/response protocol. This still works. I get a valid ljsession cookie, but any time I try and use it for something else, like posting or logging in, I get an "invalid password" error message from the server. Anybody have any ideas? |
|