简体   繁体   English

Google 对话流 PERMISSION_DENIED 异常

[英]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...所以我想有几件事要检查......

  • Make sure the Project ID is correct.确保项目 ID 正确。 Your session path should be 'projects/<Project ID>/agent/sessions/<Session ID>'.您的会话路径应为“projects/<Project ID>/agent/sessions/<Session ID>”。
  • Make sure you are using a service account with the Dialogflow API Client role.确保您使用的是具有 Dialogflow API 客户端角色的服务帐号。
  • Try getting it to work in API Explorer尝试让它在API Explorer 中工作

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:我们需要检查以下几点:

  1. You are right project ID:您是正确的项目 ID:
  2. IAM role should be ADMIN : Admin Project > Owner(Full access to all Dialogflow (console and API) and GCP resources. Can use console to create agent.) IAM 角色应该是 ADMIN : Admin Project > Owner(拥有对所有 Dialogflow(控制台和 API)和 GCP 资源的完全访问权限。可以使用控制台创建代理。)

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.

相关问题 Google Pub/Sub 上的 GRPC 权限被拒绝 [错误 7] - GRPC Permission denied on Google Pub/Sub [ERROR 7] Elastic Beanstalk 部署失败、权限被拒绝、mkdir - Elastic Beanstalk deployment failure, permission denied, mkdir 尝试在 Docker 容器内构建 C# Protobuf 项目时出现奇怪的“权限被拒绝” - Strange “Permission denied” when trying to build C# Protobuf project inside Docker container PermissionError: [Errno 13] Permission denied: '/usr/local/lib/python3.8/dist-packages/grpc/__init__.py' - PermissionError: [Errno 13] Permission denied: '/usr/local/lib/python3.8/dist-packages/grpc/__init__.py' Win10,戈兰。 协议-I。 --go_out=plugins=grpc: 。 proto/hello/hello.proto.: 权限被拒绝 - Win10,Goland. protoc -I . --go_out=plugins=grpc: . proto/hello/hello.proto .: Permission denied 尝试执行 Google Cloud API 时 GRPC 中的异常 - Exception in GRPC when trying to execute Google Cloud API 使用Python进行Dialogflow v2 Beta 1更新的意图 - Dialogflow v2 Beta 1 Update Intent with Python Dialogflow V2并将请求主体中的参数传递给Webhook - Dialogflow V2 and passing parameters in request body to webhook DialogFlow V2 gRPC(c#)(更新实体等) - DialogFlow V2 gRPC (c#) (updating entities, etc.) DialogFlow StreamingDetectIntentResponse不返回ResponseId,QueryText,Transcript或除LanguageCode之外的任何内容 - DialogFlow StreamingDetectIntentResponse doesn't return ResponseId, QueryText, Transcript or anything except LanguageCode
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM