1

Googleクラウドプリントで試しています。クラウド印刷の /search API は、printerid と xsrf トークンを取得するために使用されます。データを投稿して応答を取得しようとしていますが、投稿するたびにリモートサーバーがエラーを返しました: (403) 禁止されています..クロスドメインの問題またはどのような問題ですか?

     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 ();
4

1 に答える 1

1

Authorization: Bearer <access token here>Google がリクエストを認証するには、ヘッダーを渡す必要があります。URL で clientid パラメータを渡すだけでは十分ではありません。

アクセス トークンを取得する方法の詳細については、開発者ガイドを参照してください。

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

于 2014-08-12T18:57:24.977 に答える