【问题标题】:Google Indexing API 3 with Python - URL_UPDATED giving 403 Error使用 Python 的 Google Indexing API 3 - URL_UPDATED 给出 403 错误
【发布时间】:2021-02-03 15:15:40
【问题描述】:

我正在尝试 Google 的 Indexing API。

使用以下代码请求内容索引:

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)

输出:

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

在 Search Console 中交叉检查用户权限。用户拥有完全权限。

服务电子邮件正确,已在开发者控制台中验证。

请指教。

【问题讨论】:

    标签: python-3.x google-api-python-client google-indexing-api


    【解决方案1】:

    截至日期(21 年 2 月 3 日),来自 Google Search Console 的新所有者无法添加到任何经过验证的资源中。但是我们可以使用old Google Search Console 来添加新的所有者。

    您可以在此处选择您的财产并添加新所有者。

    你就完成了!

    快乐编码:)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-11-09
      • 2016-10-27
      • 2022-09-28
      相关资源
      最近更新 更多