Skip to main content
AlphaNiFi
Bronze ⭐️⭐️⭐️
June 27, 2024
Question

Using dynamic property with StandardOauth2AccessTokenProvider

Hi, 

I am looking to use invokehttp with StandardOAuth2AccessTokenProvider controller to automatically get Access Token and make the API call with the token. The requirement to get token has an extra field compared to standard OAUTH token :

Below is the curl command. It includes extra key called auth_chain.

 

curl --location 'https://xyedfrg.xom/access_token' \
--header 'content-type: application/x-www-form-urlencoded' \
--data-urlencode 'username=test' \
--data-urlencode 'password=test' \
--data-urlencode 'client_id=F1234rdcfhkv' \
--data-urlencode 'client_secret=test-secret' \
--data-urlencode 'grant_type=password' \
--data-urlencode 'auth_chain=OAuthLdapService'
 
But this is how the StandardOAuth2AccessTokenProvider looks:
AlphaNiFi_0-1719460304719.png

If I add auth_chain as property it errors out saying :

AlphaNiFi_1-1719460339925.png

How can I make this OAUTH call to get token using invoke http.

*please note, cannot use the option provided here (https://community.cloudera.com/t5/Support-Questions/NIFI-Is-it-possible-to-make-a-x-www-form-urlencoded-POST/m-p/339398), as it exposes the credentials in data provenance and application layer and network layer too.

 

2 replies

VidyaSargur
Community Manager
Community Manager
June 27, 2024

@AlphaNiFi, Welcome to our community! To help you get the best possible answer, I have tagged our NiFi experts @SAMSAL @steven-matison @MattWho who may be able to assist you further.

Please feel free to provide any additional information or details about your query, and we hope that you will find a satisfactory solution to your question.

Translate
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.
saquibsk
Gold ⭐️⭐️
June 27, 2024

Hello,

We you can try something like this.

Step 1 : Add an InvokeHTTP Processor to Generate the Token

Step 2: Extract Token Using EvaluateJsonPath Processor:

Step 3: Use the Token in a InvokeHTTP

Thanks,

Translate
Shakib M.