'TALEND: How to store refresh token required in tRest component?

This question is the linked from my previous question of how can we use "tRest" to fetch API data. API which is related to OAuth, has provided access and refresh token. What blocks me now, is:

  1. how can we store all the tokens? Is there a specific component to do this?
  2. Access token will expire after one hour, then need to generate new access token (gain new access token) by using the refresh token.

This is so far what I've done in the Talend job. Successfully, fetch the data by providing access token as API authorization.

tRest job

What probably the best way to enable kind of like "auto-refresh" and set the new access token without manually refresh it and copy-and-paste everytime I wanna do fetching?



Solution 1:[1]

enter image description here

The way I do it, is to use 2 tRest components. The first one is used for authentication: it stores the access token in a context variable. The second uses that access token by using your context variable, and sends the needed request.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 rveerd