5

Google Translate API を使用して送信されたテキストを翻訳する SMS (テキスト メッセージング) アプリを構築しようとしています。私は App Engine をセットアップし、oauth を選択せず​​にパブリック API キー アクセスを選択し、Google にクレジット カード番号を提供しないとできないことに気付いた後に手動でクォータ制限を設定し、請求を設定するという 8000 ステップのプロセス全体をセットアップしました。 、そして最後に「許可されたリファラーの編集」に到達し、次のように設定しました:

*

...デバッグ中に、コードが存在する実際の URL に変更する予定です。

アスタリスクを使用しても機能しません。Apigee など、サイバースペースのどこからでも接続を許可するために使用する必要がある Google Translate API v2 パブリック API リファラー ルールの構文は何ですか? 現在、この呼び出し (実際のキーの代わりに MY_KEY_HERE を使用):

https://www.googleapis.com/language/translate/v2?key=MY_KEY_HERE&q=hello%20world&source=en&target=de

戻り値:

{
  "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."
  }
}
4

1 に答える 1

7

質問に答えるには、「HTTP リファラー (Web サイト) からの要求を受け入れる」フィールドを空のままにしておくことができます。キーには「すべてのリファラーが許可されています」(動作確認済み)が含まれます。

キーが危険にさらされる可能性があるため、リファラーを許可することはお勧めできません。ユースケースから判断すると、翻訳対象のテキストを受け入れて翻訳済みのテキストを返すエンドポイントを持つことができます。実際の翻訳 API 呼び出しは、OAuth2 を使用してエンドポイントで行われ、API にアクセスします。

于 2014-12-02T14:35:38.797 に答える