代码之家  ›  专栏  ›  技术社区  ›  Beaudry Chase

如何使用TranslationServiceClient类创建TranslationServiceClient?

  •  0
  • Beaudry Chase  · 技术社区  · 5 年前

    你好,谢谢你阅读我的问题。

    Google.Cloud.Translation.V2 Google.Cloud.Translate.V3 我们正在使用 TranslationClient 但是我们需要使用 TranslationServiceClient (来自V3库。) 我在实例化一个 翻译服务客户端

    TranslationClient.Create(GoogleCredential.FromJson("{\"the credentials\"}"));
    

    通过阅读文档,我很清楚 如果没有默认设置,则需要使用 TranslationServiceClientBuilder 把证件给他。我找不到任何示例,所有代码段都使用 TranslationServiceClient.Create()

    0 回复  |  直到 5 年前
        1
  •  2
  •   Beaudry Chase    5 年前

    因为目标是创造一个 TranslationServiceClient 使用json作为身份验证,一种方法如下:

    TranslationServiceClient client = new TranslationServiceClientBuilder {
                            JsonCredentials = "{\"the credentials\"}"
                        }.Build()
    

    https://cloud.google.com/docs/authentication/production#passing_the_path_to_the_service_account_key_in_code