31
Views
1
Comments
Struggling to integrate google translate API

Hi all,

I'm trying to integrate Google's Cloud Translations API in to an app and finding it fairly confusing to do so. I was wondering if anyone had successfully integrated one of Google's POST API's and be willing to give a few pointers around OAuth etc.

The Authentication bit is my main concern...

In my understanding, in order to call the Translate API, we need to input our gcloud token which is generated from the below.

The thing is, I am not quite understanding what the gcloud auth print-access-token is. I would love to see an example outlined if anyone has one!

I think once this is figured out then I won't be too far from being able to integrate it fully. I've set up a Auth client, set up the project etc etc.

Looking forward to hearing any response.

Thankyou!

Hii @Max Winter Leinweber,

gcloud auth print-access-token  is a token that you need to pass into API to call it. it provide you a Bearer token. 

In curl you can call like by run these command 

ACCESS_TOKEN=$(gcloud auth print-access-token) // store the token in ACCESS_TOEKN variable



curl -X POST -H "Authorization: Bearer $ACCESS_TOKEN" \      // pass the token in API header Authorization

     -H "Content-Type: application/json" \

     --data '{"q": "Hello, world!", "target": "fr"}' \

     "https://translation.googleapis.com/language/translate/v2"


In outsystems to get this token you need to use google authentication forge component

https://www.outsystems.com/forge/component-overview/10251/google-authentication-core


it documentation is very helpful you can read that also to understand the use of it as well as there is one forge component available for demo only of some popular google APIs will give you an idea related authentiacation.

https://www.outsystems.com/forge/component-overview/10274/google-components-demo

https://www.outsystems.com/forge/component-overview/10274/google-components-demo


--------------------------------

you may also need to install google authentication management to manage and configure google projects connections. Leverages the Google Authentication Core component. 


Hope this will help you.

Thanks & Regards,

Sanjay Kushwah

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.