I'm attempting to do a post for google Real Time Indexing. I'm simply attempting to send an empty atom to google - I'm mainly testing the shell for what will be an amp post in th efuture. I'm getting the following error for my empty atom post:
"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."
}
I followed the link above and saw that I don't have a permission to view what's there... I was given a .json api-project file that I thought would work as an authentication file, I'm not sure if the issue is with using the "api-project.json" file or something else. Here is my basic script producing the above error:
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();
Any guidance here will be much appreciated. Thanks a lot.
The above script is fine - there were few issues outside the script. First one was our domain name was not set for the project with google, and the second one was the file I was using as credentials. Once I got the right file, I got response 200 back.