更新时间:2023-09-10 16:11:34
我发现如何对凭证进行硬编码,而无需将其保存在JSON文件中。这是在这里的文档:
I found how to hard-code the credentials without the need to save them in a JSON file. It was in this documentation here:
https://googlecloudplatform.github.io/google-cloud-node/#/docs/language/0.7.0/guides/authentication
下面是一个调用Language API的示例。
Below is an example that calls the Language API.
var language = require('@google-cloud/language')({
projectId: '',
credentials: {
client_email: '',
private_key: '',
}
});
language.detectEntities('Axel Foley is from Detroit').then(function(data) {
var entities = data[0];
var apiResponse = data[1];
});