【发布时间】:2025-12-09 01:20:20
【问题描述】:
我正在 LabVIEW 中访问 .NET DLL 以获取 google 翻译 API (Google.Cloud.Translation.V2.dll),并尝试通过命令提示符设置“GOOGLE_APPLICATION_CREDENTIALS”,如 Google 关于如何设置的示例所示一切都让翻译 API 工作。它似乎不起作用,当我运行我的代码时,我收到“缺少有效的 API 密钥”错误 (403)。我想我需要以编程方式设置密钥,但我无法在任何地方找到任何关于如何以编程方式设置 API 密钥的文档或示例。下面是我在尝试将一些德语文本翻译成英语时收到的 .NET 错误。
Google.GoogleApiException: Google.Apis.Requests.RequestError
The request is missing a valid API key. [403]
Errors [
Message[The request is missing a valid API key.] Location[ - ] Reason[forbidden] Domain[global]
]
我是否需要访问不同的 DLL 来设置 API 密钥?我下载了所有这些(因为它们是依赖项,并且我不确定在 LabVIEW 中访问 Google API 时我需要什么)并查看了我可以在所有这些中使用的潜在方法。这些是他们:
Google.Cloud.Translation.V2.dll、Google.Apis.Translate.v2.dll、Google.Api.Gax.dll、Google.Api.Gax.Rest.dll、Google.Apis.Auth.dll、Google .Apis.Auth.PlatformServices.dll、Google.Apis.Core.dll、Google.Apis.dll、Google.Apis.PlatformServices.dll、Newtonsoft.Json.dll、System.Interactive.Async.dll
【问题讨论】:
标签: .net google-api labview google-translation-api