Support Questions

Find answers, ask questions, and share your expertise

How to get the access token by invoking NIFI Rest API

avatar
Expert Contributor

I am invoking an API command (nifi-api/access/token) to get the access token. But i am getting blank output. we have LDAP configured in NiFi Cluster and i am able to login to NiFi UI using my credentials. I have started exploring the NiFi rest API for the first time. Any help would be appreciated !!

Thank you in Advance,

Subash

1 ACCEPTED SOLUTION

avatar

@subash sharma

Here is the command you need, just fill in your appropriate values:

curl 'https://nifi-host:port/nifi-api/access/token' -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' --data 'username=ldap-username&password=ldap-password' --compressed —insecure

And there you go, this will return the token you need.

The subsequent curl commands will need the token returned as part of the command:

-H 'Authorization: Bearer token-returned'

View solution in original post

4 REPLIES 4

avatar
@subash sharma

Here is the format of the command you need to get a token:

curl 'https://nifi-host:port/nifi-api/access/token' -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' --data 'username=ldap-username&password=ldap-password' --compressed —insecure

Then add the following to all of your subsequent curl commands

-H 'Authorization: Bearer token-returned’

avatar

@subash sharma

Here is the command you need, just fill in your appropriate values:

curl 'https://nifi-host:port/nifi-api/access/token' -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' --data 'username=ldap-username&password=ldap-password' --compressed —insecure

And there you go, this will return the token you need.

The subsequent curl commands will need the token returned as part of the command:

-H 'Authorization: Bearer token-returned'

avatar
Expert Contributor

Thank you @Wynner, I am able to get the access token using your code. can you please recommend the Rest API documentation which i should follow.

avatar

@subash sharma

The Rest API documentation will be found at the URL: https://nifi-host:port/nifi-docs/rest-api

Just replace the the nifi-host and port values with your information.