I had a scenario where I need to convert the curl command into a python snippet in order to trigger the API Trigger of Application Integration. This is the curl command:
curl -X POST -H "Content-Type: application/json" -d '{"trigger_id":"api_trigger/trigger_id", "inputParameters": {"partyName": {"stringValue": "sample_string"}}}' 'https://region-integrations.googleapis.com/v1/projects/project/locations/-/integrations/integrationName:execute' -H "Authorization: Bearer $(gcloud auth print-access-token)"
I have written the python snippet in this way:
Solved! Go to Solution.
I would recommend using the official python library for Google Cloud APIs. The repo is here
Please note, at the moment we support the v1alpha APIs.
I would recommend using the official python library for Google Cloud APIs. The repo is here
Please note, at the moment we support the v1alpha APIs.
@Former Community Member ,
Thank you for the solution!! I am able to get the access tokens now. Is there any way to skip this authorization part. We wanted to let the end-user get the results quickly by calling the API Trigger. We wanted to let the users access the information even if they don't have the Google account ( This will fail here as the users should authenticate ). Is there any mechanism by which we can bypass this OAuth part?
No, that is not possible. The Execute API is a Google API (integrations.googleapis.com) and therefore always protected by Google OAuth. If you want to open the API to users who don't have Google Account, please consider a gateway like Apigee. You can implement other techniques to secure the API (or keep it open, but accessible via a private network).
@Former Community Member ,
Thank You for the quick response. I am having a last doubt regarding the same topic (regarding the setting of login_hint and access_type). I have posted this here - https://www.googlecloudcommunity.com/gc/Integration-Services/Application-Integration-Regarding-OAuth-for-API-Trigger/td-p/542635. Can you please provide your inputs regarding this.
Thank You.
I am not familiar with how App Engine works. Cloud Run and Cloud Functions are associated with service accounts. Any code running in Cloud Run or Functions automatically obtain tokens from the SA configured for the Run/Functions.