我正在尝试google cloud print。云打印的/search api用于获取打印机it和xsrf token..so im发布数据并尝试获取响应,但每次我发布im时远程服务器返回一个错误:(403) Forbidden..is it跨域问题或什么问题?
string str= TextBox1.Text;
var request = (HttpWebRequest)WebRequest.Create("https://www.google.com/cloudprint/search?output=json&clientid=" + str);
request.Method = "POST";
SetupWebRequest (request);
string postData = "This is a test that posts this string to a Web server.";
byte[] byteArray = Encoding.UTF8.GetBytes (postData);
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = byteArray.Length;
Stream dataStream = request.GetRequestStream();
// Write the data to the request stream.
dataStream.Write(byteArray, 0, byteArray.Length);
// Close the Stream object.
dataStream.Close();
WebResponse response = request.GetResponse ();发布于 2014-08-13 02:57:25
您必须传递Authorization: Bearer <access token here>头,以便谷歌对您的请求进行身份验证。仅在URL中传递clientid参数是不够的。
有关如何获取访问令牌的详细信息,请参阅开发人员指南:
https://stackoverflow.com/questions/24569562
复制相似问题