允许Google翻译API的所有参考规则(v2)?

hue*_*nix 5 api google-api google-translate gcloud

我正在尝试构建一个SMS(短信)应用程序,该应用程序使用Google Translate API来翻译发送给它的文本.我已经设置了App Engine以及选择公共API密钥访问的整个8000步过程,而不是选择oauth,手动设置配额限制后意识到它不会让我不给Google一个信用卡号,然后设置结算,最后到"编辑允许的引用者",我设置为:

*
Run Code Online (Sandbox Code Playgroud)

...当我正在调试时,我打算将其更改为代码将存在的实际URL.

使用星号不起作用.Google Translate API v2公共API引用规则的语法是什么我必须使用它来允许来自网络空间的任何地方的连接,例如Apigee?目前这个调用(用MY_KEY_HERE代替实际的键):

https://www.googleapis.com/language/translate/v2?key=MY_KEY_HERE&q=hello%20world&source=en&target=de
Run Code Online (Sandbox Code Playgroud)

返回:

{
  "error":  {
    "errors":  [
       {
        "domain": "usageLimits",
        "reason": "accessNotConfigured",
        "message": "Access Not Configured. The API is not enabled for your project, or 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 configuration.",
        "extendedHelp": "https://console.developers.google.com"
      }
    ],
    "code": 403,
    "message": "Access Not Configured. The API is not enabled for your project, or 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 configuration."
  }
}
Run Code Online (Sandbox Code Playgroud)

Nik*_*aev 7

要回答您的问题,您可以将"接收来自这些HTTP REFERERS(网站)的请求"字段留空.然后密钥将"允许任何引用"(确认工作).

允许任何推荐人并不是一个好主意,因为您的密钥可能会受到损害.根据您的用例判断,您可以使用一个Endpoint来接受翻译文本并将其翻译.实际的Translate API调用将在端点上使用OAuth2来访问API.