Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Note: You may notice some temporary visual or styling issues in the Community. Our vendor is actively investigating.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Use Bearer Token obtained in previous step to Authenticate tRESTClient

I retrieved an OAuth2.0 Bearer Token through a REST API call using tREST. Once retrieved, the bearer token is stored as JSON string in tLogRow. Is it possible to add this value to the tRESTClient component for authentication? The bearer token expires every 1 or 2 hours - so I need to pass the Bearer Token dynamically to the tRESTClient or tREST component to make GET requests.

 

 

Labels (3)
8 Replies
Anonymous
Not applicable
Author

Hello,

You can have one tRESTClient get a token:
https://tools.ietf.org/html/rfc6749#section-4.4.2
and then use this token to configure another tRESTClient. Let us know if it helps.

Best regards

Sabrina

Anonymous
Not applicable
Author

Thanks xdshi - how would I pass the response from the first tRESTClient into the Header of another tRESTClient?

Anonymous
Not applicable
Author

You'll want to use a tExtractJSONFields component to retrieve only the bearer token.  You can then either pass this (as the row value) into the http headers section in the tRestClient, or you can can store in a global variable (see tSetGlobalVar), then use this global in subsequent api calls (assuming the token hasn't expired)

Manoj_MUTHURAJA
Creator
Creator

Hi,

I am also working  tRest composant which is bit different from t_RestClient.I have posted my question in the community,I paste the link below:

https://community.talend.com/t5/What-s-new-and-announcements/Error-using-get-method-in-t-rest-client...

 

I would appreciate if you can leave some comments for my post.

Thanks in advance,

Manoj

FD3
Contributor
Contributor

Here you are my simple way to manage this issue, using tExtractJSONFields and tMap, avoiding GlobalVariables.

I decided to share my experience as it took some time to me fix this issue


Use Bearer Token obtained in previous step to Authenticate tRESTClient.pdf
thalychris
Contributor
Contributor

Hi FD, 
This is helpful indeed.
Nevertheless, could you please expand the first tMAP ("tMap_1") component from your job (the one that comes right after the tExtractJSONFields and before the second tRESTClient?

 

I am new with Talend and that's the part I am missing to propagate the token_type and access_token values to my HTTP header.

 

Thanks so much for the support.

 

Chris

 

FD3
Contributor
Contributor

Not sure if I have understood what you need. I attach the tMap required by you. Please just note the names you insert in tMap row on the left are reported on the tExtractJsonField before it.0683p000009MZfb.png

thalychris
Contributor
Contributor

Hi FD,

Thank you so much for the quick reply.

This solved my issue.

Have a great day and stay safe.

Chris