Created 02-21-2024 02:00 AM
I want to stop a processor on the same machine with restApi but I get an authorization error when I call the rest api.I can solve this problem with bearer token, but since the token has expired, I need to change the bearer token manually again.Is there a way I can authorize automatically?
This is the part where I call the API in the script:
def post = new URL(NifiBaseUrl.value + NifiComponentId.value).openConnection();
post.setSSLSocketFactory(sslContext.getSocketFactory())
post.setRequestMethod("PUT")
post.setDoOutput(true)
post.setRequestProperty("Content-Type", "application/json")
post.getOutputStream().write(content.getBytes("UTF-8"));
post.getResponseCode()
Error:
java.io.IOException: Server returned HTTP response code: 401 for URL
Created 02-26-2024 07:32 AM
@plapla
What you have encountered is not an error. NiFi is telling you that the client/user Identity derived from the clientAuth certificate in your keystore is not authorized for them mentioned NiFi authorization policy that is needed for the specific rest call being made.
You'll need to authorize client/user for "execute code" restricted components policy:
NiFi UI --> global menu --> policies --> access restricted components --> execute code
If you found any of the suggestions/solutions provided helped you with your issue, please take a moment to login and click "Accept as Solution" on one or more of them that helped.
Thank you,
Matt
Created 09-05-2024 07:55 AM
@Salmidin
Please create a new community question with the details of your issue. It seem unrelated to this thread issue. The "Policies" missing from the global menu indicates your NiFi is either using Single User Authorizer (default out of box) or is not setup to be secure.
NiFi needs to be configured with a production ready authorizer for the "Polices" and "Users" options to be visible in the NiFi Global menu.
Fell free to ping me @MattWho in your new community question.
Thanks,
Matt
Created 02-26-2024 10:29 PM
I create a user with certificate DN.As you said, I gave this user "execute code" permission.This way the problem is solved.
The problem was not solved without creating a user