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

穿精又带淫゛_ 提交于 2020-04-13 16:49:19

问题


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.


回答1:


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




回答2:


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



来源:https://stackoverflow.com/questions/54571984/indexing-api-403-permission-denied-failed-to-verify-the-url-ownership

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!