Search code examples
restapache-nifi

How to pass credential to NiFi rest api


I have enabled LDAP authentication for Apache NiFi-1.1.1.

I can able to access NiFi web UI after logged in with LDAP user.

When I try to access REST API with basic authentication /process-groups/root, it shows

Unable to perform the desired action due to insufficient permissions. Contact the system administrator.

  • How to pass credential to NiFi REST API?
  • How to access NiFi REST API with the token?

Solution

  • When authenticating via LDAP, the NiFi REST API will require the client pass along a token with each request. To obtain a token, you'll need to pass the credentials to authenticate.

    curl 'https://localhost:8443/nifi-api/access/token' -H 'Accept-Encoding: gzip, deflate, br' -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' -H 'Accept: */*' --data 'username=<user>&password=<pass>' --compressed
    

    This request will return the token that you'll need to pass in the headers of each subsequent request. For instance:

    curl 'https://localhost:8443/nifi-api/flow/current-user' -H 'Accept-Encoding: gzip, deflate, sdch, br' -H 'Authorization: Bearer <token>' -H 'Accept: application/json, text/javascript, */*; q=0.01' --compressed