由于我已经在我的计算机上本地安装了Google云控制台应用程序,因此当我的JAVA服务器拨打谷歌翻译时,我收到此错误:
Exception in thread "Thread-22" com.google.cloud.translate.TranslateException: 400 Bad Request
{
"error": {
"code": 400,
"message": "The API Key and the authentication credential are from different projects.",
"errors": [
{
"message": "The API Key and the authentication credential are from different projects.",
"domain": "global",
"reason": "badRequest"
}
],
"status": "INVALID_ARGUMENT"
}
}
at com.google.cloud.translate.spi.v2.HttpTranslateRpc.translate(HttpTranslateRpc.java:61)
at com.google.cloud.translate.spi.v2.HttpTranslateRpc.detect(HttpTranslateRpc.java:87)
at com.google.cloud.translate.TranslateImpl$3.call(TranslateImpl.java:79)
at com.google.cloud.translate.TranslateImpl$3.call(TranslateImpl.java:76)
at com.google.api.gax.retrying.DirectRetryingExecutor.submit(DirectRetryingExecutor.java:93)
at com.google.cloud.RetryHelper.runWithRetries(RetryHelper.java:49)
at com.google.cloud.translate.TranslateImpl.detect(TranslateImpl.java:76)
at com.google.cloud.translate.TranslateImpl.detect(TranslateImpl.java:104)
at com.exceed.providers.googleapi.GoogleTranslateConnector.detectLanguage(GoogleTranslateConnector.java:49)
at com.exceed.providers.googleapi.GoogleTranslateConnector.detectLanguageWithConfidence(GoogleTranslateConnector.java:53)
at com.exceed.services.ConversationManagerService.handleUnknownLanguage(ConversationManagerService.java:369)
at com.exceed.services.ConversationManagerService.processMessage(ConversationManagerService.java:227)
at com.exceed.services.FBWebHookService.processMessage(FBWebHookService.java:210)
at com.exceed.services.FBWebHookService.processMessage(FBWebHookService.java:198)
at com.exceed.services.FBWebHookService.handleAudio(FBWebHookService.java:181)
at com.exceed.services.FBWebHookService.processMessageByType(FBWebHookService.java:150)
at com.exceed.services.FBWebHookService.processRequest(FBWebHookService.java:108)
at com.exceed.providers.fbmessenger.FBWebHook$1.run(FBWebHook.java:47)
at java.lang.Thread.run(Thread.java:748)
我尝试使用Google密钥或我计算机中安装的任何其他密钥来查找某个环境变量 - 但一无所获。
为了清楚起见,该错误仅在我已安装gcloud控制台的本地计算机中上升..
感谢您的帮助!
答案 0 :(得分:0)
已解决: 在我的.config目录中,有googleCloudConfig,其中包含一个apiKey,我将其删除,一切正常。