Closed xuiqzy closed 5 months ago
Hi @xuiqzy, thank you for your report!
I put a quick sample together while we work on updating the docs.
from google.auth import default
from google.auth.transport.requests import AuthorizedSession
SCOPES = [ "https://www.googleapis.com/auth/indexing" ]
ENDPOINT = "https://indexing.googleapis.com/v3/urlNotifications:publish"
credentials, _ = default(scopes=SCOPES)
authed_session = AuthorizedSession(credentials=credentials)
# 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\": \"http://example.com/jobs/42\",
\"type\": \"URL_UPDATED\"
}"""
response = authed_session.request('POST', ENDPOINT, json=content)
print(response.status_code)
print(response.text)
I did not test it, but I hope it can unblock you in the interim.
Documentation for Indexing API is still using old oauth2client library and not google-auth. It also never mentions to install either oauth2client or google-auth but then gives code samples that won't work with just installing
google-api-python-client
. Please update both issues.The deprecation page of oauth2client said to file a bug here by linking here.