Support Questions

Find answers, ask questions, and share your expertise

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!