Our Community is getting an upgrade! To get everything ready for the relaunch, we’ll be placing the site in read-only mode starting September 21st.
We really appreciate your understanding while we get things set up behind the scenes. Catch up on all the exciting details about the move here.
Need help or have questions? Drop us a line at [email protected]

Support Questions

Find answers, ask questions, and share your expertise
Announcements
Share your experience with Cloudera on G2 and get a $25 Amazon Gift card.
Hi, I'm CLEO! Something exciting is coming to the Community. Stay Tuned!

Not able to use the generated token in NIFI Rest API

avatar
Explorer

I am trying to access the NIFI using Rest API. I am using python requests library. I am able to generate the token using username and password but when I am trying to use the token to get the expiration of the token or the list of counters processors that I have created I am getting it is unauthorized.

import requests
response = requests.post("https://127.0.0.1:8443/nifi-api/access/token?username=<username>&password=<password>",headers={"Content-Type":"application/x-www-form-urlencoded"},verify=False) # if verify is true it will throw verification failed
token = response.content.decode() # got the token

#checking the token expiration
response = requests.get("https://127.0.0.1:8443/nifi-api/access/token/expiration",headers={"Accept":"*/*","Authorization":"Bearer {}".format(token)}) # using the generated token

print(response)
"Unauthorized"

I am able to get the response json using the same token through postman. So, I am not able to understand it. Is it because I am not verifying and not using any certificates causing the issue. Please anyone help me out here. Thanks!
@stevenmatison can you please look into it.

2 REPLIES 2

avatar
Explorer

I have found the issue, and I have rectified it. Sorry, for the inconveniences.

avatar

@rupeshh , make a new post and describe your solution, then click Accept As Solution!!    Then this post will be available in future for anyone experiencing similar.   Great job getting it rectified!