【问题标题】:Google Translate service account 403 dailyLimitExceeded error谷歌翻译服务帐户 403 dailyLimitExceeded 错误
【发布时间】:2017-07-18 22:15:27
【问题描述】:

我正在配置 Node.JS 服务器以使用 Google 翻译 API。到目前为止,我已经完成了以下工作:

  1. 设置 Google 帐户
  2. 添加信用卡并启用计费
  3. 创建项目
  4. 为项目启用 Google 翻译 API
  5. 为项目*创建两个服务帐号并保存 JSON 密钥文件

*一个服务帐户用于本地开发,一个帐户用于部署应用程序。

示例代码(打字稿):

import * as Translate from '@google-cloud/translate';

export async function translate(text: string, to: string): Promise<string> {

    let translation = '';

    const googleTranslate = Translate({
        projectId: PROJECT_ID,
        keyFilename: PATH/TO/KEY_FILE
    });

    const response = await googleTranslate.translate(text, to);

    if (Array.isArray(response[0])) {
        for (let t of response[0]) {
            translation += t;
        }
    }
    else {
        translation = response[0];
    }

    return translation;

}

我在我的工作站上测试了本地和开发密钥并成功翻译。 但是,在部署的环境下(不同机器,动态IP)不起作用。出现如下错误:

错误响应:

{
    domain: 'usageLimits',
    reason: 'dailyLimitExceeded',
    message: 'This API requires billing to be enabled on the project. Visit https://console.developers.google.com/billing?project=GOOGLE_PROJECT_ID to enable billing.',
    extendedHelp: 'https://console.developers.google.com/billing?project=project=GOOGLE_PROJECT_ID'
}

计费已启用,所以我错过了什么?

【问题讨论】:

    标签: amazon-ec2 chef-infra google-translate google-api-nodejs-client


    【解决方案1】:

    已解决!

    私钥中未转义的字符在厨师食谱食谱中被破坏。现在,一个不同的进程在初始化时将文件同步到服务器,并且翻译工作正常。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-09-16
      • 2013-04-18
      • 2015-04-04
      • 2011-11-07
      • 2010-12-31
      相关资源
      最近更新 更多