Support Questions
Find answers, ask questions, and share your expertise

To get authentication token using InvokeHttps and use the token in subsequent RestApi call in ApacheNiFI

Explorer

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!

 

2 REPLIES 2

Re: To get authentication token using InvokeHttps and use the token in subsequent RestApi call in ApacheNiFI

Master Guru

@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

Re: To get authentication token using InvokeHttps and use the token in subsequent RestApi call in ApacheNiFI

Community Manager

@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,
Community Manager


Was your question answered? Make sure to mark the answer as the accepted solution.
If you find a reply useful, say thanks by clicking on the thumbs up button.

Learn more about the Cloudera Community: