我有一个 GAE 应用程序,所以我选择:
- 公共(public)访问 API
- 浏览器(或者我应该选择服务器)
- *.mysite.appspot.com/*, *.googleapis.com/*, http://localhost:8080/*
我进行 API 调用:
from lib.googleapiclient.discovery import build
service = build("customsearch", "v1",developerKey="xxxx")
但我收到错误:
"There is a per-IP or per-Referer restriction configured on your API key and the request does not match these restrictions. Please use the Google Developers Console to update your API key configuration if request from this IP or referer should be allowed."
我该怎么办?
最佳答案
除了您确实应该按照 Alex 的指示使用 API 服务器 key 这一事实之外,错误消息还告诉您 API 请求来自未经授权的 IP/域,因为该 IP/域尚未在 API 上列入白名单 key 。
我将使用允许的任何 IP 设置新的服务器 key (未定义 IP/范围)。
关于python - 如何获取 google 自定义搜索 api 的开发者 ID?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29065504/