Google Indexing API 3 with Python - URL_UPDATED giving 403 Error

816 Views Asked by At

I am trying Google's Indexing API.

Using the below code to request content indexing:

from oauth2client.service_account import ServiceAccountCredentials
import httplib2

SCOPES = [ "https://www.googleapis.com/auth/indexing" ]
ENDPOINT = "https://indexing.googleapis.com/v3/urlNotifications:publish"

# JSON Key File Location
JSON_KEY_FILE = "service_account_file.json"

credentials = ServiceAccountCredentials.from_json_keyfile_name(JSON_KEY_FILE, scopes=SCOPES)

http = credentials.authorize(httplib2.Http())

content = """{
  "url": "https://digisapient.com/blog/website-international-seo-implementation/",
  "type": "URL_UPDATED"
}"""

response, content = http.request(ENDPOINT, method="POST", body=content)
print(response.status)
print(content)

Output:

403
b'{\n  "error": {\n    "code": 403,\n    "message": "Permission denied. Failed to verify the URL ownership.",\n    "status": "PERMISSION_DENIED"\n  }\n}\n'

Cross checked user permission in the Search Console. The user has Full right.

Service Email is correct, validated in the Developer Console.

Please advice.

1

There are 1 best solutions below

0
On

As of date (3rd Feb'21) from Google Search Console new owner cannot be added to any verified property. But we can use the old Google Search Console to add a new owner.

Here you can select your property and add a new owner.

enter image description here

And you're done!

Happy Coding :)