Closed LvffY closed 1 year ago
Two initial thoughts:
@Chaffelson Thanks for your answer :)
/system-diagnostics
and it succeeds in REST API while failed with the Python APIimport requests
from pprint import pprint
auth = ("user", "pwd")
req = requests.get(f"https://nifi_url/system-diagnostics", auth=auth)
pprint(req.json())
I looked in my ranger audit, but didn't see any failure :(
Now I'm a bit confused ^^'
Ah ok, can I suggest you try using nipyapi.utils.set_endpoint
Nipy doesn't expect you to modify the underlying configs directly, although you can in many cases. For simple activities like you are trying, I created helper methods to ensure that login and logout are completed correctly and with the right security context.
@Chaffelson I did not see this function, should be useful !
Unfortunately, I still got the same error :(
import nipyapi
nipyapi.utils.set_endpoint(endpoint_url="https://nifi_url/nifi-api", username="user", password="password")
parameters = nipyapi.parameters.get_parameter_context('my_id', identifier_type='id')
print(parameters)
Try:
import nipyapi
nipyapi.utils.set_endpoint(endpoint_url="https://nifi_url/nifi-api", username="user", password="password", login=True)
parameters = nipyapi.parameters.get_parameter_context('my_id', identifier_type='id')
print(parameters)
@Chaffelson Same error :(
Ok I think we need to sync up on what is not working, hit me up on the Apache NiFi slack and we can diagnose it
After a call with @Chaffelson (thanks again ;)) we have a working setup :
We think that our problem is only related to our environment (which is a CDP Public Cloud from Cloudera) but in case anyone fall into this, you need to setup the force_basic_auth to True
To work, I did the following code :
import nipyapi
############ For Nifi server
nipyapi.config.nifi_config.force_basic_auth = True
nipyapi.config.nifi_config.username = "user"
nipyapi.config.nifi_config.password = "password"
nipyapi.utils.set_endpoint(endpoint_url=nifi_api)
print(nipyapi.canvas.get_root_pg_id())
########### For Nifi registry
nipyapi.config.registry_config.username = "user"
nipyapi.config.registry_config.password = "password"
nipyapi.config.registry_config.force_basic_auth = True
nipyapi.utils.set_endpoint(self.nifi_reg_endpoint)
I think we should add an enhancement to the set_endpoint method to allow a flag for basic_auth usage
Description
I'm trying to request my nifi installation. My server is a Cloudera server behind a ranger/kerberos authentication.
What I Did
I'm trying to set up a simple request :
With these lines I get the following errors
On the other side, if I'm doing simple rest api calls, it works :
I think that others requests are made but I'm not aware of which requests.
Urgency
It is not really blocking but I would really like to use this API instead of the RAW REST API. The latest I have an answer on this, the toughest it will be on my side to replace REST API calls by the API.