Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Indexing API 403 Permission denied. Failed to verify the URL ownership

I want to execute the code from the example:

    require_once 'google-api-php-client/vendor/autoload.php';

    $client = new Google_Client();

    // service_account_file.json is the private key that you created         for your service account.
    $client->setAuthConfig('service_account_file.json');
    $client->addScope('https://www.googleapis.com/auth/indexing');

    // Get a Guzzle HTTP Client
    $httpClient = $client->authorize();
    $endpoint =         'https://indexing.googleapis.com/v3/urlNotifications:publish';

    // Define contents here. The structure of the content is described in the next step.
    $content = "{
      \"url\": \"http://example.com/jobs/42\", //I used real url from my homepage
      \"type\": \"URL_UPDATED\"
    }";

    $response = $httpClient->post($endpoint, [ 'body' => $content ]);
    $status_code = $response->getStatusCode();

But in response, I get an error: 403 "Permission denied. Failed to verify the URL ownership.".

  1. I created service account and read the file in my application.
  2. Site verified. screeen1
  3. Access to service account is full. screeen2
  4. I used domain without "www" and https in search console and in my app.
  5. Indexing API enabled and requests come.

What else needs to be done and checked to gain access?

Answer

Full access !== Owner. I need to read the documentation better.

like image 321
WP Punk Avatar asked Feb 07 '19 11:02

WP Punk


2 Answers

As mentioned, your service account should be "owner" (not "full"). With the new search console, it is almost impossible to set the service account to Owner, luckily, you can use the old Webmasters tool.

https://support.google.com/webmasters/thread/4763732?hl=en

like image 108
Rodrigo R. Coelho Avatar answered Oct 09 '22 03:10

Rodrigo R. Coelho


Full access !== Owner. I need to read the documentation better.

like image 24
WP Punk Avatar answered Oct 09 '22 04:10

WP Punk