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: 
LNYAKA1625749060
Contributor
Contributor

Call Rest api with OAuth2.0 by using trest component

I have an url https:// myTokenUrl/token.

In Postman, I add an Authorization Basic Auth 

add username and password, ain the body, i select :x-www-form-urlencoded

and i set grant_type key and client_credentials value

and i sent my post request 

I retrieve a json response which contains an access_token which expires every 1 hour.

After i sent a get request with this url https:// mysecondUrl/users and 

i set a bearer token (access_token)

it 's work very fine

I want to do the same operation in talend by using trest component, but i doesn't 

how can i set these parameters : Authorization : Basic Auth , username : username value,

password : password value and sent my post request to get access token to pass it in the second

get request with OAuth2.0 Bearer Token

How can i do this? 

Labels (5)
3 Replies
gjeremy1617088143

Hi @LELO NYAKA​ , use tRestClient component you can set the auth in the settings.

https://help.talend.com/r/7NvFnkWpbH8Gy3Rm6mUXnw/V4DayMUD1TrO522ClO0fBw

Send me love and kudos

 

JFryk
Contributor
Contributor

@guenneguez jeremy 

The link in this question appears to be no longer available, I am having a very similar issue, do you still have these details?

Thank you!

jeoste
Creator
Creator

Hello,

Using tRESTClient you can achieve this in 3 steps :
1. tJava / tjavarow : you define a String variable that contains, for example, the JSON you will send with POST method to get the token

2 . tRESTClient : using POST method and the URL you will retrieve the content with the "response" link of the component. Use t extractjson to get the content of the token only. Put this into globalVar

3. Later in the job when you need to send data, put the url and the token using authentification OAuth2

jeoste_0-1707129011427.png