首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >403个Google翻译API的每日配额

403个Google翻译API的每日配额
EN

Stack Overflow用户
提问于 2017-12-26 01:04:04
回答 3查看 1.8K关注 0票数 1

我跟随使用说明使用Google。我有:

  1. 创建了一个项目
  2. 启用帐单,并在账单帐户上有300美元
  3. 启用翻译API并确保配额很高
  4. 生成一个带有Admin角色的服务帐户,并下载JSON
  5. 将以下行添加到我的.zshrc中: 导出GOOGLE_APPLICATION_CREDENTIALS=/pathto/Holodeck-421412.json
  6. 其来源如下: 源~/..zshrc

然而,我的nodeJS代码和curl返回:

代码语言:javascript
复制
 code: 403,
  errors:
   [ { message: 'Daily Limit Exceeded',
       domain: 'usageLimits',
       reason: 'dailyLimitExceeded' } ],
  response: undefined,
  message: 'Daily Limit Exceeded' }

我的卷发:

代码语言:javascript
复制
curl --header "Content-Type: application/json" --header "Authorization: Bearer `gcloud auth print-access-token`" --show-error -s "https://translation.googleapis.com/language/translate/v2" -d @translate-request.json

并翻译-request.json:

代码语言:javascript
复制
{
  "q": "The quick brown fox jumped over the lazy dog.",
  "source": "en",
  "target": "es",
  "format": "text"
}

我的NodeJS代码:

代码语言:javascript
复制
// Imports the Google Cloud client library
const language = require('@google-cloud/language');
const Translate = require('@google-cloud/translate');

// Instantiates a client
const client = new language.LanguageServiceClient();

// Your Google Cloud Platform project ID
const projectId = 'myproject ID';

// Instantiates a client
const translation = new Translate({
    projectId: projectId
});


// The text to analyze
let text1 = 'Hello, world!';

const translate = (text) => {
    const target = 'en';

    translation
        .translate(text, target)
        .then(results => {
            const translation = results[0];

            console.log(`Text: ${text}`);
            console.log(`Translation: ${translation}`);
        })
        .catch(err => {
            console.error('ERROR:', err);
        });
}


const analyze = (text) => {

    const document = {
        content: "good very good amazingly good",
        type: 'PLAIN_TEXT',
    };

// Detects the sentiment of the text
    client
        .analyzeSentiment({document: document})
        .then(results => {
            const sentiment = results[0].documentSentiment;
            console.log(`Sentiment score: ${sentiment.score}`);
            console.log(`Sentiment magnitude: ${sentiment.magnitude}`);
        })
        .catch(err => {
            console.error('ERROR:', err);
        });
}

translate(text1);
analyze(text1);

这让我感到困惑,因为自然语言API正在工作,所以服务帐户似乎运行正常。对此有什么看法吗?我有3个小时试图通过这个意想不到的障碍,我已经做了任何牦牛剃须,我可以考虑,包括打开新的项目/服务帐户/ API密钥和谷歌集团论坛(它的设计只是让我更欣赏StackOverflow .:)

----UPDATE----

当我将每天字符的配额从1,000,000更改为另一个值时,似乎开始工作15秒左右(2-3次请求),然后返回到403错误。然后,如果我再次改变配额,我会得到另一轮2-3次请求。这就好像请求本身正在更改配额,或者在15-20秒之后取消更改。

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2018-01-03 20:27:28

问题应该已经解决了,从现在开始,请再试一次,看看你是否还在看到这个问题,如果必要的话重新打开问题#70990743

票数 1
EN

Stack Overflow用户

发布于 2017-12-28 04:43:59

我也有同样的问题,我在Google问题跟踪器:https://issuetracker.google.com/issues/70990743中找到了这个bug

票数 1
EN

Stack Overflow用户

发布于 2019-03-27 09:39:57

你可以用配额来解决这个问题。你应该增加“每天字符”和“字符每秒”。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47973060

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档