Google Diaglogflow - Authentication using service account key

Hi Folks,

I started working on building a custom chatbot on a wappler page. I developed the project on Google’s dialogflow. And I need to make a ‘detect intent’ API call from my website to Google Cloud Platform. Reference: https://cloud.google.com/dialogflow/docs/quick/api#detect_intent

I created an API action in Wappler and followed the instructions pertaining to the url, method and data. However, all of Dialogflow documentation suggests using a JSON key file for authentication. I extracted the key file from GCP successfully using the instructions at https://dialogflow.com/docs/reference/v2-auth-setup

However, I am unable to figure out how I can actually pass the file for authentication through Wappler. The Oauth actions only allow username or client ID/secret methods to authenticate. However, given that I am not trying to access user data but only the project data, it looks like I cannot use those methods. I found this link which clarified that aspect: https://cloud.google.com/docs/authentication/

Can someone help me understand how to authenticate the API action?
FYI - I tried passing the ‘Bearer key’ as an authorization header but that didn’t work. I created an Oauth2.0 client key from Google Cloud and created an Oauth2 server action in wappler but that didn’t work either. I think there needs to be a way to pass that file. Other folks building custom chatbots wrote a few lines in PHP to pass that file. Eg.:
$client = new \Google_Client();
$client->useApplicationDefaultCredentials();
$client->setScopes([‘https://www.googleapis.com/auth/dialogflow’]);
$client->setAuthConfig($secretFile);
$httpClient = $client->authorize();

Community Page
Last updated: