问题
I am trying to access a Google DialogFlow from a Windows Java application. I have the environment variable, GOOGLE_APPLICATION_CREDENTIALS
, properly set and I can call other Google APIs. However, when I call:
DetectIntentResponse response = sessionsClient.detectIntent(session, queryInput);
I receive a grpc exception:
PERMISSION_DENIED: IAM permission 'dialogflow.sessions.detectIntent' on 'projects/newagent-a0ef5/agent' denied.Session Path: projects/NewAgent/agent/sessions/xxxx
"newagent-a0ef5" is the project ID of my flow. "xxxx" is just a random Session ID token.
I understand that I have to enable dialogflow.sessions.detectIntent
access, but I cannot figure out where. I created a custom role with that value and added it to the three IAM accounts associated with my flow. I have also enabled the DialogFlow API.
Does anyone know where I add this missing permission?
回答1:
I did all the IAM steps properly, but I was passing the wrong Project ID to detectIntent. So I guess a couple things to check...
- Make sure the Project ID is correct. Your session path should be 'projects/<Project ID>/agent/sessions/<Session ID>'.
- Make sure you are using a service account with the Dialogflow API Client role.
- Try getting it to work in API Explorer
回答2:
There are following things we need to check:
- You are right project ID:
- 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.)
Ref to add IAM user(don't forget to choose rule as Admin): https://dialogflow.com/docs/reference/v2-auth-setup
回答3:
I had the same problem when I was creating a chatbot. I solve this by using a Dialogflow API Client role. I also had to change my ruby version from 2.6 to 2.5.1.
It is important to remember that the GOOGLE_APPLICATION_CREDENTIALS
have to point to the key .json file. To avoid problems set the path to the json file in the .bashrc file. So you don't have execute export GOOGLE_APPLICATION_CREDENTIALS="[PATH]"
every time you restart your machine.
回答4:
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). After I changed it to ProjectID, it started working. HTH
回答5:
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.
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):
set GOOGLE_APPLICATION_CREDENTIALS=C:\Users\Owner\Desktop\reactbot\config\ddssa-adietv-aasddss.json
来源:https://stackoverflow.com/questions/49673575/google-dialogflow-permission-denied-exception