Site icon PrestaShop | Magento | CRM Modules

PrestaShop 403 error on indexing api

A 403 error on an Indexing API usually means permission denied or authentication issue.
For Google Indexing API, common reasons are:

Common Causes of 403 Error

  1. Service Account not added
    • Add your Google Cloud service account email as Owner in:
      • Google Search Console
    • Use the exact service account email ending with:
      xxxxx@xxxxx.iam.gserviceaccount.com
  2. Indexing API not enabled
    • In Google Cloud Console:
      • APIs & Services → Library
      • Enable:
        • Indexing API
  3. Wrong API Scope
    Use this scope:
    https://www.googleapis.com/auth/indexing
    
  4. Website not verified
  5. Using Indexing API for unsupported pages
    Google officially allows Indexing API mainly for:
    • Job Posting pages
    • Live Stream pages

    Normal blog/product pages may return errors or limited success.

  6. JSON Key issue
    • Make sure the downloaded JSON credentials file is correct and active.
  7. Wrong endpoint
    Correct endpoint:
    https://indexing.googleapis.com/v3/urlNotifications:publish
    

Example PHP Request

$client = new Google_Client();
$client->setAuthConfig('service-account.json');
$client->addScope('https://www.googleapis.com/auth/indexing');

$httpClient = $client->authorize();

$response = $httpClient->post(
    'https://indexing.googleapis.com/v3/urlNotifications:publish',
    [
        'json' => [
            'url' => 'https://example.com/page-url',
            'type' => 'URL_UPDATED'
        ]
    ]
);

echo $response->getBody();

 

Exit mobile version