2017-03-16 2 views
0

Google Real-Time Indexingの投稿を作成しようとしています。私は単にGoogleに空の原子を送信しようとしています - 私は主に、実際に何がアンプのポストになるのかについてシェルをテストしています。私は私の空の原子ポストのために、次のエラーを取得しています:JAVA:Google Real Time Indexing API 403エラー - プロジェクトでインデックスAPIが使用されていません。

"error": { 
    "code": 403, 
    "message": "Google Indexing API has not been used in project api-project-xxx before or it is disabled. 
Enable it by visiting https://console.developers.google.com/apis/api/indexing.googleapis.com/overview?project=api-project-xxx then retry. 
If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry."  
} 

私は上記のリンクをたどって、私はそこに何を表示する権限を持っていないことがわかりました...私は.jsonのAPI-を与えられましたプロジェクトファイル、私は認証ファイルとして動作すると思った、私は問題が "api-project.json"ファイルまたは何かを使用している場合はわからない。上記のエラーを生成する私の基本的なスクリプトは次のとおりです:

String scopes = "https://www.googleapis.com/auth/indexing"; 
String endPoint = "https://indexing.googleapis.com/xxx..."; 
genericUrl = new GenericUrl(endPoint); 

httpTransport = GoogleNetHttpTransport.newTrustedTransport(); 
requestFactory = httpTransport.createRequestFactory(); 
jsonFactory = new JacksonFactory(); 
InputStream in = IOUtils.toInputStream("api-project.json"); 

String atom = "< ... basic atom shell is here .... >" 
request = requestFactory.buildPostRequest(genericUrl, ByteArrayContent.fromString(null, atom)); 
credentials = GoogleCredential.fromStream(in, httpTransport, jsonFactory).createScoped(Collections.singleton(scopes)); 
credentials.initialize(request); 
HttpResponse response = request.execute(); 

ここでのご指摘は大歓迎です。どうもありがとう。

答えて

0

上記のスクリプトは問題ありません。スクリプト外の問題はほとんどありません。最初は私たちのドメイン名はGoogleのプロジェクトには設定されていませんでした。もう1つは私が資格情報として使用していたファイルでした。正しいファイルを取得したら、私は200の応答を返します。

関連する問題