微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

使用 Python 的 Google Indexing API 3 - URL_UPDATED 给出 403 错误

如何解决使用 Python 的 Google Indexing API 3 - URL_UPDATED 给出 403 错误

我正在试用 Google 的索引 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 中交叉检查用户权限。用户拥有完全权限。

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

请指教。

解决方法

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

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

enter image description here

大功告成!

快乐编码:)

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。