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.
I would recommend setting up two dataflows here.
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.
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.
@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.