Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google dialogflow PERMISSION_DENIED Exception

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?

like image 797
Andrew Prokop Avatar asked Apr 05 '18 13:04

Andrew Prokop


1 Answers

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
like image 137
Keeth Avatar answered Sep 18 '22 00:09

Keeth