-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
I have created a Dialogflow agent with some intents. However, when I try to integrate it into my java backend, it seems to be accessing the wrong application default credentials.
I can confirm that it is verifying authentication is successful because the console logs the correct project ID (weather-checker-50074) when I run this code:
// Set the session name using the sessionId (UUID) and projectID (my-project-id)
try (SessionsClient sessionsClient = SessionsClient.create()) {
SessionName session = SessionName.of(projectId, sessionId);
System.out.println("Session Path: " + session.toString());
And it works fine for even this piece of code:
// Build the query with the TextInput
Builder textInput = TextInput.newBuilder().setText(text).setLanguageCode(languageCode);
System.out.println("Passed text input stage");
QueryInput queryInput = QueryInput.newBuilder().setText(textInput).build();
System.out.println("Passed query input stage");
However, when I try to get the response back from dialogflow, I get an error. Here is the code for getting the response back from Dialogflow.
DetectIntentResponse response = sessionsClient.detectIntent(session, queryInput);
System.out.println("Detected Intent");
ERROR [stderr] (default task-108) com.google.api.gax.rpc.PermissionDeniedException: io.grpc.StatusRuntimeException: PERMISSION_DENIED: Dialogflow API has not been used in project 764086051850 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/dialogflow.googleapis.com/overview?project=764086051850 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.
The weird thing is, my project number is not 764086051850. So it seems like it's not accessing the correct credentials. I have tried the solution given in the link below but it still doesn't seem to work. Any help would be appreciated. Thanks!