Dialogflow授权的简便方法 [英] Dialogflow easy way for authorization

查看:122
本文介绍了Dialogflow授权的简便方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否存在将Dialogflow代理连接到我的node.js代码的简便方法?当我将此代码与从Dialogflow代理的设置页面获取的正确projectID一起使用时,出现以下错误:

Does there exist an easy way to connect my Dialogflow agent to my node.js code? When I use this code with the correct projectID taken from the Dialogflow agent's settings page, I have the following error:

错误:获取应用程序默认凭据时发生意外错误:无法加载默认凭据.浏览到 https://developers.google.com/accounts/docs/application-default -凭证以获取更多信息.

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.

const sessionClient = new dialogflow.SessionsClient();
const sessionPath = sessionClient.sessionPath(projectId, sessionId);

我访问了该页面,但是对于我想让我感到困惑的东西(他们引用了其他API和很多设置),我该如何解决呢?

I visited the page, but for what I want I think is quite confused (they quotes other API and a lot of setting), how can I resolve this?

我想从文件中获取信息并加载所有信息,而不会安装丢失的API或其他一些信息...

I would like to do it taking informations from a file and loading all without installing losts of APIs or some other...

推荐答案

该文档没有很好的记录,但是最简单的身份验证方法是使用Google云平台控制台上提供的JSON文件.

It is not very well documented, but the easiest way to authenticate is using the JSON file provided on your google cloud platform console.

const sessionClient = new dialogflow.SessionsClient({
    keyFilename: '/path/to/google.json'
});
const sessionPath = sessionClient.sessionPath(projectId, sessionId);

这也适用于所有其他客户端. ContextsClientsEntityTypesClient等.

This also works for all the other clients. ContextsClients, EntityTypesClient and so on.

这篇关于Dialogflow授权的简便方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆