Log in

No account? Create an account
LiveJournal Client Discussions [entries|archive|friends|userinfo]
LiveJournal Client Discussions

[ userinfo | livejournal userinfo ]
[ archive | journal archive ]

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?

[User Picture]From: chriswiegand
2006-02-07 05:20 am (UTC)


Sorry, can't help you (I'm writing a client for PocketPC, but I chose VB.Net and I chose the Flat client/server interface). If you want to see my VB.Net code, however, and how I did my interfacing, it'll be up on SourceForge soon...
(Reply) (Thread)