[英]Google dialogflow PERMISSION_DENIED Exception
I am trying to access a Google DialogFlow from a Windows Java application.我正在尝试从 Windows Java 应用程序访问 Google DialogFlow。 I have the environment variable,
GOOGLE_APPLICATION_CREDENTIALS
, properly set and I can call other Google APIs.我已经正确设置了环境变量
GOOGLE_APPLICATION_CREDENTIALS
并且我可以调用其他 Google API。 However, when I call:但是,当我打电话时:
DetectIntentResponse response = sessionsClient.detectIntent(session, queryInput);
I receive a grpc exception:我收到一个 grpc 异常:
PERMISSION_DENIED: IAM permission 'dialogflow.sessions.detectIntent' on 'projects/newagent-a0ef5/agent' denied.Session Path: projects/NewAgent/agent/sessions/xxxx
PERMISSION_DENIED:“projects/newagent-a0ef5/agent”上的 IAM 权限“dialogflow.sessions.detectIntent”被拒绝。会话路径:projects/NewAgent/agent/sessions/xxxx
"newagent-a0ef5" is the project ID of my flow.
“newagent-a0ef5”是我的流程的项目 ID。 "xxxx" is just a random Session ID token.
“xxxx”只是一个随机的会话 ID 令牌。
I understand that I have to enable dialogflow.sessions.detectIntent
access, but I cannot figure out where.我知道我必须启用
dialogflow.sessions.detectIntent
访问,但我不知道在哪里。 I created a custom role with that value and added it to the three IAM accounts associated with my flow.我使用该值创建了一个自定义角色,并将其添加到与我的流关联的三个 IAM 账户中。 I have also enabled the DialogFlow API.
我还启用了 DialogFlow API。
Does anyone know where I add this missing permission?有谁知道我在哪里添加这个缺少的权限?
I did all the IAM steps properly, but I was passing the wrong Project ID to detectIntent.我正确地完成了所有 IAM 步骤,但我将错误的项目 ID 传递给了detectIntent。 So I guess a couple things to check...
所以我想有几件事要检查......
I had the same problem when I was creating a chatbot.我在创建聊天机器人时遇到了同样的问题。 I solve this by using a Dialogflow API Client role.
我通过使用 Dialogflow API 客户端角色解决了这个问题。 I also had to change my ruby version from 2.6 to 2.5.1.
我还必须将 ruby 版本从 2.6 更改为 2.5.1。
It is important to remember that the GOOGLE_APPLICATION_CREDENTIALS
have to point to the key .json file.重要的是要记住
GOOGLE_APPLICATION_CREDENTIALS
必须指向关键的 .json 文件。 To avoid problems set the path to the json file in the .bashrc file.为避免出现问题,请在 .bashrc 文件中设置 json 文件的路径。 So you don't have execute export
GOOGLE_APPLICATION_CREDENTIALS="[PATH]"
every time you restart your machine.因此,您不必每次重新启动机器时都执行 export
GOOGLE_APPLICATION_CREDENTIALS="[PATH]"
。
There are following things we need to check:我们需要检查以下几点:
Ref to add IAM user(don't forget to choose rule as Admin): https://dialogflow.com/docs/reference/v2-auth-setup参考添加 IAM 用户(不要忘记选择规则作为管理员): https : //dialogflow.com/docs/reference/v2-auth-setup
In my case the error occurred because GOOGLE_CLOUD_PROJECT was set with Project Name (a word in mixed case), but it should be ProjectID (a word lower case).在我的情况下,发生错误是因为 GOOGLE_CLOUD_PROJECT 设置为项目名称(大小写混合的单词),但它应该是 ProjectID(小写单词)。 After I changed it to ProjectID, it started working.
在我将其更改为 ProjectID 后,它开始工作。 HTH
HTH
i also had this error, it could be that you're failing to set environment on the json credentials, make sure it is correct, i didn't need an admin role for mine.我也有这个错误,可能是你没有在 json 凭据上设置环境,确保它是正确的,我不需要管理员角色。
to set path for GOOGLE_APPLICATION_CREDENTIALS on cmd on wherever directory you are, point your json file as if you would do on environment varialbes(will be removed when you close cmd):要在 cmd 上的任何目录上设置 GOOGLE_APPLICATION_CREDENTIALS 的路径,请像在环境变量上一样指向 json 文件(关闭 cmd 时将被删除):
set GOOGLE_APPLICATION_CREDENTIALS=C:\\Users\\Owner\\Desktop\\reactbot\\config\\ddssa-adietv-aasddss.json设置 GOOGLE_APPLICATION_CREDENTIALS=C:\\Users\\Owner\\Desktop\\reactbot\\config\\ddssa-adietv-aasddss.json
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.