问题
PermissionDenied: 403 IAM permission 'dialogflow.sessions.detectIntent' on 'projects/XXXX-live/agent' denied.
I have used the DialogFlow client as a role while creating the service.
What could be the problem?
回答1:
When I was playing around with permissions with service accounts, I also encountered the same problem. I created a completely new service account and then gave it the client role, and it worked for some unknown reason. I would suggest trying to create another account and then giving it the client role and seeing if it works for that account. Also, this isn't necessarily a kosher fix per say, but if you give the account the admin role, then your problem will also be solved.
Edit: At first I thought it might have to do with how the service accounts were created (cloud console vs. command-line), but it seems that's not the case. For some reason it's just the first service account that you create that a client role doesn't work for.
回答2:
I solved my error by doing this
from google.oauth2 import service_account
credentials = service_account.Credentials.from_service_account_file(
'C:\\Users\\ashis\\Downloads\\id.json')
def create_intent(project_id, display_name, training_phrases_parts,
message_texts):
"""Create an intent of the given intent type."""
intents_client = dialogflow.IntentsClient(credentials=credentials)
# session_client = dialogflow.SessionsClient(credentials=credentials)
Then I went to the IAM settings for my project https://console.cloud.google.com/iam-admin/iam?project= and gave the dialogflow service account members a higher role(like project owner).
来源:https://stackoverflow.com/questions/51421926/dialogflow-permissiondenied-403-iam-permission-dialogflow-sessions-detectinten