Dialog api v2 - 获取应用程序默认凭据时出现意外错误:无法加载默认凭据

时间:2018-06-14 07:19:22

标签: node.js nlp google-cloud-platform dialogflow service-accounts

我正在尝试使用谷歌对话框流程实现聊天机器人应用程序。我正在暂停这个github教程format()来实现api。这是我的代码

var array = [{
    title: "a",
    date: "2018-03-29"
  }, {
    title: "b",
    date: "2018-04-13"
  }, {
    title: "c",
    date: "2018-04-12"
  }, {
    title: "leave",
    date: "2018-04-11"
  }, {
    title: "d",
    date: "2018-06-16"
  }],
  currentMonth = new Date().getMonth() + 1,
  currentYear = new Date().getFullYear(),
  events = array.filter(e => {
    var [year, month] = e.date.split('-'); // Or, var month = e.date.split('-')[1];
    return (currentMonth === +month) && (currentYear == year);
  });
console.log(events);

一旦我启动我的应用程序,我就会收到波纹管错误

var express = require('express');
var router = express.Router();
const projectId = 'my-project-id'; //https://dialogflow.com/docs/agents#settings
const sessionId = 'random no';
const query = 'hello';
const languageCode = 'en-US';
// Instantiate a DialogFlow client.
const dialogflow = require('dialogflow');
const sessionClient = new dialogflow.SessionsClient();

// // Define session path
// const sessionPath = sessionClient.sessionPath(projectId, sessionId);
/* GET home page. */
router.get('/', function(req, res, next) {


});

module.exports = router;

所以我试图找出问题并发现我需要使用服务帐户设置身份验证。我这样做下载了包含所需键的密钥文件并运行命令

(node:6436) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 3): Error: Unexpected error while acquiring application default credentials: Could not load the default credentials. Browse to https://developers.google.com/accounts/docs/application-default-credentials for more information.
(node:6436) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 4): Error: Unexpected error while acquiring application default credentials: Could not load the default credentials. Browse to https://developers.google.com/accounts/docs/application-default-credentials for more information.

但这样做也没有做任何事。有没有办法从代码手动提供此密钥文件,而不是设置环境变量。

1 个答案:

答案 0 :(得分:3)

根据此linkgithub repo here,您应该可以在ec1L3$mean <- apply(ec1L3[2:ncol(ec1L3)],1, mean) # Calculating by row the mean cc1L3$mean <- apply(cc1L3[2:ncol(cc1L3)],1, mean) # Calculating by row the mean ## Add each line to each graphic geom_smooth(data=ec1L3, aes(Time,mean, colour= 'experimental1L3')) geom_smooth(data=cc1L3, aes(Time,mean, colour= 'control1L3')) 中设置凭据:

const sessionClient