我需要一个完整的 C# 示例,说明如何使用 37Signals OAuth,如下所述:http ://groups.google.com/group/37signals-api/browse_thread/thread/86b0da52134c1b7e
我可以获得第 3 点中提到的限时验证码,但从那里我无法成功发布以兑换代码并取回令牌。
这是我到目前为止所做的,目前代码返回 401 Unauthorized 错误:
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();
欢迎任何想法和建议,请:)谢谢!