Skip to main content
Announcements
Introducing a new Enhanced File Management feature in Qlik Cloud! GET THE DETAILS!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Using OAuth 2.0 with Talend to Access Google APIs

This tutorial was originally written in 2014 for my website. Although the Google screenshots may be slightly out of date and I wrote this using version 5.5.1 of Talend, you should still be able to make use of this. I have attached a copy of the job and a copy of the parameters file I used for this.

 

Google make use of the OAuth 2.0 protocol for authentication for (I think, but am happy to be corrected) all of their services. They do a pretty good job of describing the protocol. Once you have read through the documentation you should have a better idea of what you are doing, which should make this easier. The Google documentation is here.

 

The first thing that needs to be done is to create a Google Project. This is described below....

 

Create a Google Project

 



To see the whole post, download it here
Labels (5)
30 Replies
powerchip
Contributor
Contributor

I juste found this in the palette tGoogleDriveConnection

Maybe this can be easier

It's a Drive connection but I think it will work with other apis from Google, I'll need time to test it

Anonymous
Not applicable
Author

Hi @rhall 

Thanks for this helpful tutorial,

I have a probelem that when i get the bearer from Trestclient, i want to enter the bearer and send a json file(content informations) to the api but i don't know how?

you will find attached a screen of my job.

Thanks in advance.

 

 


bearer.PNG
Anonymous
Not applicable
Author

Hi @shima,

 

I am not sure that this is directly related to this tutorial. Could I ask you to post a new question and give a bit more information as to what you have done and what you wish to achieve?

 

Regards

 

Richard

Anonymous
Not applicable
Author

Actually, we are trying to make a post (json) api call using Oauth2.0 authentication. Please find below step, what we have done with curl command. Exactly, same thing needs to be implemented in Talend.

Step1:-
Passed curl command to fetch access token below:-

curl -v -H "Content-Type: application/x-www-form-urlencoded" -X POST --data "client_id=8BYA26jcZ4cYcivjX0oUABvefmmeqErN&client_secret=lWRoPehoFCmypPls&grant_type=client_credentials&scope=DHub" https://slot1.org009.t-dev.corp.nutty.com/v2/oauth/token --cert /usr/local/certs/nutty.com.crt --key /usr/local/certs/nutty.com.key -v –k

Step2:-
From first step, we will be getting access token:-

{"access_token":"k420G8LGaNQSUXNhih0T3xgAIwyE","token_type":"Bearer","expires_in":"3599"}

Step3:-
Using this access token in curl command we have to make another POST API call:-

curl -v -X POST -H "Content-Type: application/json" -H "Authorization: Bearer k420G8LGaNQSUXNhih0T3xgAIwyE" -H "Correlation-Id: b8905354-a164-b480-9fb2-75c2d1a8498x" -H "Source-System: Dhub" --data @usage2.json https://slot1.org009.t-dev.corp.nutty.com/application/b2b-bds-dev/v1.0/billing-events/700001276364/s... --key /usr/local/certs/nutty.com.key --cert /usr/local/certs/nutty.com.crt -v –k

Please see a snapshot of data, what we are trying to post through usage2.json file:-

{
"instanceId": "b4ee9fc9-7f50-49f4-a90f-32b0ffcf3c73",
"units": 120,
"Source-System": "D-Hub",
"effectiveDate": "2019-07-05T06:00:16.000Z",
"billingSpecId": "GSS_01",
"eventType": "GMM"
}

Final Output, which we expect:-

{"code":201,"status":201,"message":"Created"}

This is what we are trying to achieve in Talend. Is it possible to first authenticate using Oauth2.0 authenticationa nd then pass the access token to make a POST api call.

indrajeet183
Contributor
Contributor

Hi,
Thanks for wonderful guide for oauth, I'm currently referring this for my project.
I'm having difficulty in tMsgBox on linux(Fedora 29), I don't know if this is default behaviour of tMsgBox but whenever I click outside(want to copy URL) anywhere or do ALT+TAB (for opening browser) the msgbox get's disappear. But the job doesn't get killed it stays running.

 

Is there any workaround for this or this is only because I'm on linux?

Anonymous
Not applicable
Author

It sounds like the message box has lost focus. Try minimising the Studio or using alt+tab until the message box is viewable.

indrajeet183
Contributor
Contributor

Hi, I already checked that too, I thought it's minimized but I can't find it in ALT+TAB, also I can't find it in my task bar too. 

I will try to switch desktop environment just to see if it's working or not.

Also just for confirmation I tried same on Windows and voila the problem is not there .....

 

indrajeet183
Contributor
Contributor

Got it, ALT+TAB doesn't work but if I minimise only using mouse I can see the msgbox. Thanks for the help. 0683p000009MACn.png
Also I wanted to ask one more question, right now I'm doing all this in local environment so can you please tell me how can this deployed on production and if I'm able to only access production instance using SSH how I can deal with auth as there wont be messagebox.
Anonymous
Not applicable
Author

You will need to separate this job into 2 parts; the part which uses a refresh token to update the live auth token (+ the rest of your job) to be run on your server, the part which generates the refresh token will need to be done manually. Once the refresh token is generated, this should continue to run until your refresh token is removed or unauthorised.

indrajeet183
Contributor
Contributor

Yes, that makes sense I was thinking a hard way like maybe creating service(same redirect url) on server where it will save the auth code in existing file but I don't know if that's feasible or not.

Also I'm quite new to Talend so I don't know the best practices so can you please tell me any resources or your own suggestion for deploying and VCS?
I mostly work with integration stuff but using code so this is all new and I'm having hard time figuring out how can I deploy to production how to maintain error logs.

Also whenever you are having free time please check this https://community.talend.com/t5/Design-and-Development/Data-integration-for-Magento-to-Quick-Book/m-...