App Engine アプリ (Java) から Google クラウド プリントに新しい印刷ジョブを送信しようとしています。
プリンターの Google クラウド プリントの設定で、「印刷可能」権限を {{MY_APP_ID}}@appspot.gserviceaccount.com に設定しました。
次に、App Engine アプリから次のコードを実行します。
AppIdentityCredential credential = new AppIdentityCredential(
Arrays.asList("https://www.googleapis.com/auth/cloudprint"));
HttpRequestFactory requestFactory =
new UrlFetchTransport().createRequestFactory(credential);
Map<String, String> params = new LinkedHashMap<String, String>();
params.put("printerid", "{{PRINTER_ID}}");
params.put("title", "Title");
params.put("ticket", "{\"version\":\"1.0\", \"print\":{}}");
params.put("content", "<!DOCTYPE html>\n<html>\n<body>\nHello world!\n</body>\n</html>");
params.put("contentType", "text/html");
HttpRequest httpRequest = requestFactory.buildPostRequest(
new GenericUrl("https://www.google.com/cloudprint/submit"),
new UrlEncodedContent(params));
HttpResponse httpResponse = httpRequest.execute();
try {
System.out.println(httpResponse.parseAsString());
} finally {
httpResponse.ignore();
}
Google クラウド プリントの API は、success=false および message="User is notauthorized." の応答を返します。
ただし、応答の users フィールドが実際に ["{{MY_APP_ID}}@appspot.gserviceaccount.com"] であるため、正しいユーザーを認識しているようです。
私は何を間違っていますか?App Engine アプリをアプリ独自の権限で Google クラウド プリントに印刷する方法はありますか?