Google Translate API v3:如何使用来自Service Account Key的private_key进行身份验证?

huangapple go评论58阅读模式
英文:

Google Translate API v3: how to authenticate with private_key from Service Account Key?

问题

如何使用来自服务帐户密钥的private_key进行身份验证到Google Translate API v3?
由于v3不使用API密钥,因此应该有一种使用private_key进行身份验证的方法。

英文:

How to authenticate to Google Translate API v3 with private_key from Service Account Key?
As v3 doesn't work with api keys there should be a way of authentication but with private_key

答案1

得分: 0

import { TranslationServiceClient } from '@google-cloud/translate';

const credentials = {
 client_email: <your_service_account_email>,
 private_key: <your_private_key_from_service_account_key>
};

const translationClient = new TranslationServiceClient({
    credentials,
});

// 现在您可以使用 translationClient 执行翻译
英文:
import { TranslationServiceClient } from &#39;@google-cloud/translate&#39;;

const credentials = {
 client_email: &lt;your_service_account_email&gt;,
 private_key: &lt;your_private_key_from_service_account_key&gt;
};

const translationClient = new TranslationServiceClient({
    credentials,
});

// now you can use translationClient to perform translations

huangapple
  • 本文由 发表于 2023年7月13日 22:49:27
  • 转载请务必保留本文链接:https://go.coder-hub.com/76680744.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定