Google Indexing API Service Account(跨 Agent 共享凭证)
用途
用于 Google Indexing API 批量推送 URL(强推 hsdesign.biz 页面收录)。
凭证位置(所有 Agent 共享)
本文件同目录:env/google-indexing-service-account.json
- Vault 路径:
H:\My Drive\Jakephone\Obsidian Vault\env\google-indexing-service-account.json - Drive 同步: 位于 Obsidian Vault(Google Drive 挂载),所有设备/Agent 可访问
- Hermes 本地备份:
D:\hermes\secrets\hsdesign-seo-service-account.json
⚠️ 安全警告(2026-08-01):此密钥曾误部署到 https://hsdesign.biz/service_account.json 公开暴露(旧部署缓存中仍可获取,7天后过期)。如担心泄露可到 Google Cloud Console 轮换密钥。绝不要再放入站点部署目录!
使用方式
必须用系统 Python 3.11(Hermes venv 的 cryptography 有 _cffi_backend 问题):
"/c/Users/Sozo/AppData/Local/Programs/Python/Python311/python.exe"import json, urllib.request
from google.oauth2 import service_account
from google.auth.transport.requests import Request
with open(r'H:\My Drive\Jakephone\Obsidian Vault\env\google-indexing-service-account.json', encoding='utf-8') as f:
sa = json.load(f)
credentials = service_account.Credentials.from_service_account_info(
sa, scopes=['https://www.googleapis.com/auth/indexing'])
credentials.refresh(Request())
token = credentials.token
# 推送 URL
body = json.dumps({'url': '<URL>', 'type': 'URL_UPDATED'}).encode()
req = urllib.request.Request(
'https://indexing.googleapis.com/v3/urlNotifications:publish',
data=body,
headers={'Authorization': 'Bearer ' + token, 'Content-Type': 'application/json'})
resp = json.loads(urllib.request.urlopen(req, timeout=30).read())账号信息
- client_email:
[email protected] - project_id:
gen-lang-client-0131595820 - 需要 GSC 中 hsdesign.biz 的 Owner 权限(否则 403 Permission Denied)
配额
- 每天约 200 URL(Indexing API 限额)
- 全站 83 页一次可推完