Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PermissionDenied: 403 IAM permission 'dialogflow.intents.list'

I'm trying to get the list of the intents in my Dialogflow agent using Dialogflow's V2 APIs but have been getting the following error:


PermissionDenied: 403 IAM permission 'dialogflow.intents.list' on 'projects/xxxx/agent' denied.

I adopted the following steps:

  1. I created a new agent(with V2 APIs enabled) and a new service account for it.
  2. I downloaded the JSON key and set my GOOGLE_APPLICATION_CREDENTIALS variable to its path.

Following is my code:

import dialogflow_v2 as dialogflow

os.environ["GOOGLE_APPLICATION_CREDENTIALS"]="/home/user/folder/service-account-key.json"

client=dialogflow.IntentsClient()

parent = client.project_agent_path('[PROJECT_ID]')

for element in client.list_intents(parent):
    pass

I have made various agents and service accounts and even changed the role from Admin to Client but can't figure out any solution. I tried the following solution but didnt' work

Tried Solution: DialogFlow PermissionDenied: 403 IAM permission 'dialogflow.sessions.detectIntent'

like image 530
Pranshu Dixit Avatar asked Sep 14 '18 12:09

Pranshu Dixit


2 Answers

There is no need for creating a new Agent. You can edit the existing agents IAM.

  1. In Dialogflow's console, go to settings ⚙ > under the general tab, you'll see the project ID section with a Google Cloud link to open the Google Cloud console > Open Google Cloud.
  2. In google cloud, go to IAM Admin > IAM under tab Members. Find the name of your agents and then click on edit.
  3. Give admin permissions to the agent to give permissions to list intent.
like image 78
Rishabh Batra Avatar answered Oct 21 '22 05:10

Rishabh Batra


The problem lies in the IAM section of GCP. Probably you are making a POST request with a role that does not have the necessary authorizations.

  1. Look into your key.json file that contains the field "client_email"
  2. Proceed to the IAM page and set the relevant role with that email to a role that has posting capabilities. (e.g. Admin)

This solved my problem.

like image 5
BcK Avatar answered Oct 21 '22 06:10

BcK