<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Re: Nifi invalid access token rest api in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/Nifi-invalid-access-token-rest-api/m-p/353785#M236796</link>
    <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/100789"&gt;@KD9&lt;/a&gt;&amp;nbsp; &amp;nbsp;How long the NiFi server will validate a clients token is configured within the login-identity-providers.xml file via the following property:&lt;/P&gt;&lt;PRE&gt;Authentication Expiration&lt;/PRE&gt;&lt;P&gt;When setting up an automated process, using client tokens is not the best method.&amp;nbsp; A better option would be to authenticate your client via a client certificate.&amp;nbsp; &amp;nbsp;With a client certificate, there is not need to obtain a token.&amp;nbsp; That Client certificate will continue to work for the life of the certificate (certificates do have a valid until date set when you generate the certificate).&amp;nbsp; &amp;nbsp;So instead of passing a bearer token in your curl command, you would use your client pem key.&amp;nbsp; &amp;nbsp;The owner DN from the client certificate would be used as the user identity that you would then need to authorize in NiFi for the rest-api endpoint(s) needed for your automation.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="batang,apple gothic"&gt;If you found that the provided solution(s) assisted you with your query, please take a moment to login and click&lt;/FONT&gt;&amp;nbsp;&lt;FONT face="arial black,avant garde" color="#FF0000"&gt;Accept as Solution&amp;nbsp;&lt;/FONT&gt;&lt;FONT face="batang,apple gothic" color="#000000"&gt;below each response that helped.&lt;BR /&gt;&lt;BR /&gt;Thank you,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="batang,apple gothic" color="#000000"&gt;Matt&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 30 Sep 2022 21:31:29 GMT</pubDate>
    <dc:creator>MattWho</dc:creator>
    <dc:date>2022-09-30T21:31:29Z</dc:date>
    <item>
      <title>Nifi invalid access token rest api</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Nifi-invalid-access-token-rest-api/m-p/353697#M236771</link>
      <description>&lt;P&gt;Hello Everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We are triggering our Nifi processors (version 1.16.2 , LDAP integrated ) through Curl within cron job. Curl is invoking the processor using access token (as we moved from http call to https)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Generating access token :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;curl https://$hostip:$port/nifi-api/access/token -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' --data 'username="${ldapusername}"&amp;amp;password="${ldappassword}"' '--compressed --insecure &lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Curl invoking Nifi processor using acces token stored in variable &lt;EM&gt;$nifi_token&lt;/EM&gt; :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;curl -i -H 'Content-Type: application/json' -H 'Authorization:Bearer '$nifi_token -XPUT -d '{"id":"'${processorid }'","state":"STOPPED"}' https://$hostip:$port/nifi-api/flow/process-groups/$processorid '--insecure'&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But it is failing for token expiration :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;WWW-Authenticate: Bearer error="invalid_token", error_description="An error occurred while attempting to decode the Jwt: Expired JWT", error_uri="&lt;A title="https://tools.ietf.org/html/rfc6750#section" href="https://tools.ietf.org/html/rfc6750#section" target="_blank" rel="noopener noreferrer"&gt;https://tools.ietf.org/html/rfc6750#section&lt;/A&gt;&amp;nbsp;Server: Jetty(9.4.46.v20220331)&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can we set this access token to not expire ?&lt;/P&gt;&lt;P&gt;Or can we not used access token and using LDAP credentials within curl script to invoke the Nifi processors.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We tried modifying "nifi.security.user.jws.key.rotation.period" property to set the expiration duration in nifi.properties following&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://exceptionfactory.com/posts/2021/10/23/improving-jwt-authentication-in-apache-nifi/" target="_blank" rel="noopener"&gt;https://exceptionfactory.com/posts/2021/10/23/improving-jwt-authentication-in-apache-nifi/&lt;/A&gt;&lt;BR /&gt;&lt;A href="https://en.wikipedia.org/wiki/ISO_8601#Durations" target="_blank" rel="noopener"&gt;https://en.wikipedia.org/wiki/ISO_8601#Durations&lt;/A&gt;&lt;BR /&gt;&lt;A href="https://nifi.apache.org/docs/nifi-docs/rest-api/index.html" target="_blank" rel="noopener"&gt;https://nifi.apache.org/docs/nifi-docs/rest-api/index.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;but still it fails and the curl is unable to trigger the Nifi processor.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance !&lt;/P&gt;</description>
      <pubDate>Thu, 29 Sep 2022 19:32:55 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Nifi-invalid-access-token-rest-api/m-p/353697#M236771</guid>
      <dc:creator>KD9</dc:creator>
      <dc:date>2022-09-29T19:32:55Z</dc:date>
    </item>
    <item>
      <title>Re: Nifi invalid access token rest api</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Nifi-invalid-access-token-rest-api/m-p/353785#M236796</link>
      <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/100789"&gt;@KD9&lt;/a&gt;&amp;nbsp; &amp;nbsp;How long the NiFi server will validate a clients token is configured within the login-identity-providers.xml file via the following property:&lt;/P&gt;&lt;PRE&gt;Authentication Expiration&lt;/PRE&gt;&lt;P&gt;When setting up an automated process, using client tokens is not the best method.&amp;nbsp; A better option would be to authenticate your client via a client certificate.&amp;nbsp; &amp;nbsp;With a client certificate, there is not need to obtain a token.&amp;nbsp; That Client certificate will continue to work for the life of the certificate (certificates do have a valid until date set when you generate the certificate).&amp;nbsp; &amp;nbsp;So instead of passing a bearer token in your curl command, you would use your client pem key.&amp;nbsp; &amp;nbsp;The owner DN from the client certificate would be used as the user identity that you would then need to authorize in NiFi for the rest-api endpoint(s) needed for your automation.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="batang,apple gothic"&gt;If you found that the provided solution(s) assisted you with your query, please take a moment to login and click&lt;/FONT&gt;&amp;nbsp;&lt;FONT face="arial black,avant garde" color="#FF0000"&gt;Accept as Solution&amp;nbsp;&lt;/FONT&gt;&lt;FONT face="batang,apple gothic" color="#000000"&gt;below each response that helped.&lt;BR /&gt;&lt;BR /&gt;Thank you,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="batang,apple gothic" color="#000000"&gt;Matt&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Sep 2022 21:31:29 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Nifi-invalid-access-token-rest-api/m-p/353785#M236796</guid>
      <dc:creator>MattWho</dc:creator>
      <dc:date>2022-09-30T21:31:29Z</dc:date>
    </item>
  </channel>
</rss>

