Created on 04-15-2021 04:44 AM - edited 04-15-2021 05:25 AM
I am looking how to implement the below scenario using ApacheNiFi:
1. To get Authentication token using InvokeHTTP processor
2. Save this token in some file as this token expired in 30 min(how to write logic for checking received token is not expired or not)
3. Use this token for subsequent RESTApi call.
Thanks!
Created on 06-08-2021 07:00 AM - edited 06-08-2021 07:01 AM
@midee
I would recommend setting up two dataflows here.
Dataflow 1:
Generate FlowFile processor configured to run once very 28 minutes which is connected to an InvokeHTTP processor that is configured to get you Authentication token and write it to a FlowFile attribute. The InvokeHTTP processor then connects to PutDistributedMapCache processor to store that authentication token.
Dataflow 2:
This is the flow that will use that stored token for your next Rest API call. This flow would use a FetchDistributedMapCache processor to get the stored token and then route success to an invokeHTTP processor to make your Rest API call. If it fails, the failure and No Retry relationships should be looped back to the FetchDistributedMapCache processor so it can get auth token again (perhaps one used previous request just expired and a new one is now loaded in the map cache), so it tries your rest api call again.
If you found this addressed your query, please take a moment to login and click "Accept" on this solution.
Thank you,
Matt
Created 06-13-2021 10:55 PM
@midee, did you resolve your issue? If so, please mark the appropriate reply as the solution, as it will make it easier for others to find the answer in the future.
Regards,
Vidya Sargur,