Use Bearer Token obtained in previous step to Authenticate tRESTClient

Highlighted
Five Stars

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.

 

 

Moderator

Re: Use Bearer Token obtained in previous step to Authenticate tRESTClient

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

--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
Five Stars

Re: Use Bearer Token obtained in previous step to Authenticate tRESTClient

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

Eight Stars

Re: Use Bearer Token obtained in previous step to Authenticate 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)

2019 GARNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

Best Practices for Using Context Variables with Talend – Part 1

Learn how to do cool things with Context Variables

Blog

Migrate Data from one Database to another with one Job using the Dynamic Schema

Find out how to migrate from one database to another using the Dynamic schema

Blog

Best Practices for Using Context Variables with Talend – Part 3

Read about some useful Context Variable ideas

Blog