I'm in need of an complete C# example of how to use 37Signals OAuth as described here : http://groups.google.com/group/37signals-api/browse_thread/thread/86b0da52134c1b7e
I can get the time limited verification code as mentioned in point 3, but from there I'm not able to succesfully POST to redeem the code and get a token back.
Here's what I've done so far, at the moment the code returns a 401 Unauthorized error:
HttpWebRequest webRequest = null;
WebResponse webResponse = null;
byte[] byteArray = Encoding.UTF8.GetBytes(code);
webRequest = (HttpWebRequest)WebRequest.Create("https://launchpad.37signals.com/authorization/token?client_id=" + clientId + "&redirect_uri=" + redirectUri + "&client_secret=" + clientSecret + "&type=web_server");
webRequest.Method = "POST";
webRequest.ContentLength = byteArray.Length;
webRequest.ContentType = "application/xml','Authorization: OAuth'";
string EncryptedDetails = Convert.ToBase64String(Encoding.ASCII.GetBytes(code));
webRequest.Headers.Add("Authorization", "Token" + code);
Stream dataStream = webRequest.GetRequestStream();
dataStream.Write(byteArray, 0, byteArray.Length);
dataStream.Close();
webResponse = webRequest.GetResponse();
Any ideas and suggestions is welcome, please :) Thank you!
I suggest that you use a library which does the protocol-level work for you. The best one I know is http://www.dotnetopenauth.net/
There are usage examples in the
Samples
folder.