Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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.
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
Thanks xdshi - how would I pass the response from the first tRESTClient into the Header of another tRESTClient?
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)
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:
I would appreciate if you can leave some comments for my post.
Thanks in advance,
Manoj
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
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
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.
Hi FD,
Thank you so much for the quick reply.
This solved my issue.
Have a great day and stay safe.
Chris