英文:
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 '@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,
});
// now you can use translationClient to perform translations
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论