Kumar
Kumar

Reputation: 3990

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.

Upvotes: 4

Views: 11633

Answers (2)

Hema
Hema

Reputation: 1

try using this curl command in the terminal to get access token. "curl -X POST "https://localhost:8443/nifi-api/access/token" -H "Content-Type: application/x-www-form-urlencoded; charset=UTF-8" --data "username=&password=" --insecure"

Upvotes: 0

Matt Gilman
Matt Gilman

Reputation: 1134

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

Upvotes: 17

Related Questions