google-translate - Google Crendentials 为 NULL,我无法设置环境变量
问题描述
我正在尝试使用 ASP.Net 翻译文本框文本。在集成 Google 翻译 API 时,我进入了 TranslationClient.Create()。并且在元数据文件中,翻译客户端为空。即使我在环境变量中设置了凭据路径,但它仍然为空..如何解决它?
TranslationClient Client = TranslationClient.Create();
var text = txtCategoryName.Text;
var resp = Client.TranslateText(text, LanguageCodes.English, LanguageCodes.ChineseSimplified);
*Meta DATA file*
public static TranslationClient Create(GoogleCredential credential = null, TranslationModel model = TranslationModel.ServiceDefault);
//
// Summary:
// Asynchronously creates a Google.Cloud.Translation.V2.TranslationClient, using
// application default credentials if no credentials are specified.
//
// Parameters:
// credential:
// Optional Google.Apis.Auth.OAuth2.GoogleCredential.
//
// model:
// The default translation model to use. Defaults to Google.Cloud.Translation.V2.TranslationModel.ServiceDefault.
//
// Returns:
// The task representing the created Google.Cloud.Translation.V2.TranslationClient.
//
// Remarks:
// The credentials are scoped as necessary.
[AsyncStateMachine(typeof(<CreateAsync>d__19))]
public static Task<TranslationClient> CreateAsync(GoogleCredential credential = null, TranslationModel model = TranslationModel.ServiceDefault);
翻译客户端中的实际结果为空,而不是翻译文本
解决方案
推荐阅读
- octave - GNU octave 是否有生成对角矩阵和交换矩阵的例程?
- c# - 导航到新页面后无法引用对象属性(C#、Xamarin)
- c# - 未加载符号,xamarin 项目上的 Visual Studio 或调试器有问题
- java - android api类的访问字段
- android-studio - 如何在片段之间进行多个数据?
- string - Arduino 我如何使用 char 而不是 String(为了更好地使用内存)
- javascript - 离子反应,滚动到特定的列表项
- php - 未定义变量:产品(查看:/projects/ProjectWebsite/resources/views/shop/index.blade.php)
- linux - 为 AWS linux 安装 Tesseract
- java - 使用 Quarkus 时配置公开的 Web 服务资源