Support Questions

Find answers, ask questions, and share your expertise

using invokehttp processor to sent post request with oauth2 configuration without to get token separately

avatar
Explorer

Set "OAuth2 Access Token provider" in Invokehttp prosessor with grant type as client credentials as well as client id and client secret, thinking no need to Set Authorization Bearer token in this processor, the processor will dynamically set retrieved token with post request to get remote API response. But always to 401 error back. Not able to tell it is error from token provider or from remove API to send post request. However, if using Postman, in a post  request, I can do it successfully to get remote API response. So I am sure the Grant type, client id and clietn secret are correct. What I am missing to get it work?

 

WIl be very appreciate if NiFi experts guide me to configure invokeHttp processor for oauth2 seeteing to resolve my problem?

1 ACCEPTED SOLUTION

avatar
Explorer

Thanks STeven for your recommendation. The issue result. The invokeHttp oauth2 property looks like not able to select basic authorization from the setting or I might missing something. So have to ignore oauth2 setting and implement basic auth by sending client_id and _secret  separately to get token first and then send actual payload later from another invokehttp processor. 

Thanks for your help

View solution in original post

5 REPLIES 5

avatar

@jnifi  If you are able to get a remote API call working with Postman,  you can definitely get that to work with InvokeHttp.   Not having an oAuth2 to test with myself,  here are some suggestions:

 

  • Fully document required settings for postman
    • headers, request, post values, etc
    • duplicate them in NiFi
  • set InvokeHttp log level to DEBUG
  • tail logs/nifi-app.log while testing

When you have that operational understanding and full visibility of errors begin iterating on NiFi where you start to test all of the settings.   Getting nifi/invokeHttp outcome to match postman is much easier in this manner.  Additionally in future replies,  show screen shots of processor configs or share flow definition/template files where possible.

 

 

avatar
Explorer

Thanks Steven. Unfortunately, I have no NiFI server access so but I saw the invokehttp error not go to failure but as exception. I have all configuration and copied from Postman as much as I can. These seetings almost exact the same as Postman one except one thing. In POstman, it has "Add Authorizaton to Headers to Request Headers or Request URL (Both setting working to get token) while I could not find the same seeting in NiFi. In Nifi invokehttp processor, configured Oauth2 Access Token provider as in attached screen shot. All seting in NiFi processor are copy of Postman setting as I am able to aware of. The error message on invokehttp processor is 401 error to get token. An advice to resolve this? Thankss0.jpgS1.jpgS2.jpgS3.jpg

avatar
Explorer

Sorry on a few typos. Forgot to mentioned, in invokehttp configure, the Remote URL is the one that accept JSON payload. The Authorization Server URL is the token provider URL, both the same as in Postman setting. BUt in NiFi, got 401 error to get token. So COntroller setting may be somewhere invorrect. I could not identify that

avatar

@jnifi It sounds like you mentioned missing some headers.   If you know what they are,  you click the + on nifi invokeHttp and add them.   If you get into debug, and the log files you should be able to see the request and response objects to confirm its the correct format.   I think that will get you through the 401.

avatar
Explorer

Thanks STeven for your recommendation. The issue result. The invokeHttp oauth2 property looks like not able to select basic authorization from the setting or I might missing something. So have to ignore oauth2 setting and implement basic auth by sending client_id and _secret  separately to get token first and then send actual payload later from another invokehttp processor. 

Thanks for your help