你好,谢谢你阅读我的问题。
我正在努力将一些代码从Google.Cloud.Translation.V2转换为Google.Cloud.Translate.V3,因为我们需要使用api高级特性。我们使用TranslationClient来获取翻译(来自V2库),但是我们需要使用TranslationServiceClient (来自V3库)。我很难用我们的凭据实例化TranslationServiceClient。在V2中实现它的方法很简单:
TranslationClient.Create(GoogleCredential.FromJson("{\"the credentials\"}"));从阅读文档可以清楚地看到,要创建一个没有默认设置的TranslationServiceClient,您需要使用TranslationServiceClientBuilder并提供凭证。我找不到任何例子,所有的代码片段都使用TranslationServiceClient.Create(),它不允许任何参数。
发布于 2020-07-08 15:35:56
由于目标是使用json作为身份验证来创建TranslationServiceClient,因此这样做的一种方法如下:
TranslationServiceClient client = new TranslationServiceClientBuilder {
JsonCredentials = "{\"the credentials\"}"
}.Build()https://stackoverflow.com/questions/62784724
复制相似问题