首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >远程服务器返回错误:(403)禁止。错误

远程服务器返回错误:(403)禁止。错误
EN

Stack Overflow用户
提问于 2014-07-04 16:07:40
回答 1查看 1.2K关注 0票数 1

我正在尝试google cloud print。云打印的/search api用于获取打印机it和xsrf token..so im发布数据并尝试获取响应,但每次我发布im时远程服务器返回一个错误:(403) Forbidden..is it跨域问题或什么问题?

代码语言:javascript
复制
     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 ();
EN

回答 1

Stack Overflow用户

发布于 2014-08-13 02:57:25

您必须传递Authorization: Bearer <access token here>头,以便谷歌对您的请求进行身份验证。仅在URL中传递clientid参数是不够的。

有关如何获取访问令牌的详细信息,请参阅开发人员指南:

https://developers.google.com/cloud-print/docs/appDevGuide

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24569562

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档