Google Indexing API 403 Forbidden

I have trouble setting up the Google Indexing API.

I guess I set all permissions, but it stills shows me a 403 Forbidden-status.

from oauth2client.service_account import ServiceAccountCredentials
import httplib2

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

# service_account_file.json is the private key that you created for your service account.
JSON_KEY_FILE = "credits-6933.json"

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

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

# Define contents here as a JSON string.
# This example shows a simple update request.
# Other types of requests are described in the next step.

content = """{
  "url": "https://url.com/vanlife/",
  "type": "URL_UPDATED"
}"""

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

Did I miss something? I read the posts here already, but did everything according to them - so no duplicate here.

URL and stuff is an example in my code. Did I miss something?

snipped from google services

GSC snipped

Upvotes: 0

Views: 599

Answers (1)

After some research and reading through several tutorials, I found my issue.

I didn't activate the API itself which is in my eyes, not described on the docs.

https://console.developers.google.com/flows/enableapi?apiid=indexing.googleapis.com&credential=client_key

Followed this link and clicked on activate on the second tab. And it worked.

Upvotes: 1

Related Questions