<?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>article NPrinting: How to configure and call APIs with JWT authentication in Official Support Articles</title>
    <link>https://community.qlik.com/t5/Official-Support-Articles/NPrinting-How-to-configure-and-call-APIs-with-JWT-authentication/ta-p/1712523</link>
    <description>&lt;P&gt;This explains how to set up JWT authentication to call the NPrinting API.&lt;/P&gt;
&lt;BLOCKQUOTE class="quote"&gt;This customization is provided as is. Qlik Support cannot provide continued support of the solution. For assistance, reach out to our &lt;A href="https://community.qlik.com/t5/Official-Support-Articles/How-and-when-to-contact-Qlik-s-Professional-Services-and/ta-p/1714936" target="_blank" rel="noopener"&gt;Professional Services&lt;/A&gt; or engage in our active &lt;A href="https://community.qlik.com/t5/Integration-Extension-APIs/bd-p/qlik-sense-integration-extension-api" target="_blank" rel="noopener"&gt;Integrations forum&lt;/A&gt;.&lt;/BLOCKQUOTE&gt;
&lt;P&gt;If you do not have a certificate, for testing purposes, it is possible to use certificates generated by default by NPrinting in&amp;nbsp;C:\ProgramData\NPrinting\certificates:&lt;/P&gt;
&lt;P&gt;cert.pem&lt;BR /&gt;key.pem&lt;BR /&gt;&lt;BR /&gt;For production environments, for security purposes, we recommend that you use a certificate you have purchased or generated yourself.&lt;/P&gt;
&lt;H4&gt;&lt;FONT color="#339966"&gt;&lt;STRONG&gt;Setting up JWT authentication in the NPrinting Console&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/H4&gt;
&lt;OL&gt;
&lt;LI&gt;Go to Admin &amp;gt; Settings &amp;gt; Authentication&lt;/LI&gt;
&lt;LI&gt;Select "Enabled" for JWT authentication&lt;/LI&gt;
&lt;LI&gt;Open cert.pem in a text editor, copy the content and paste it in JWT certificate&lt;/LI&gt;
&lt;LI&gt;Choose "Authenticate user by email" and input a value for the attributes name, such as "mailaddress" (Authenticate user by Domain\Name can also be used if the user has a domain account filled in in his user information)&lt;/LI&gt;
&lt;LI&gt;Click on "Update authentication settings" in order to save.&lt;/LI&gt;
&lt;/OL&gt;
&lt;H4&gt;&lt;FONT color="#339966"&gt;&lt;STRONG&gt;Generate a JWT token&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/H4&gt;
&lt;P&gt;It is possible to use the debugger on &lt;A href="https://jwt.io" target="_blank" rel="noopener"&gt;https://jwt.io&lt;/A&gt; in order to generate a JWT token.&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Select algorithm: RS256&lt;/LI&gt;
&lt;LI&gt;In Payload, input the following:
&lt;PRE&gt;{
  "mailaddress":"&lt;STRONG&gt;youremailaddress@email.com&lt;/STRONG&gt;"
}&lt;/PRE&gt;
The email address should be the email address of an NPrinting user.&lt;BR /&gt;&amp;nbsp;&lt;/LI&gt;
&lt;LI&gt;In "Verify signature", paste the content of cert.pem in the first field and the content of key.pem in the second field.&lt;/LI&gt;
&lt;LI&gt;The JWT token is now ready to use and appear on the left.&lt;/LI&gt;
&lt;/OL&gt;
&lt;H4&gt;&lt;FONT color="#339966"&gt;&lt;STRONG&gt;Use the JWT token to call the NPrinting API:&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/H4&gt;
&lt;P&gt;Below is a PowerShell script that is calling the API using JWT authentication. The JWT token needs to be passed in the "Authorization" header and be preceded by the "Bearer" keyword, the same method can also be used in the Qlik Rest Connector or Postman.&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

add-type @"
    using System.Net;
    using System.Security.Cryptography.X509Certificates;
    public class TrustAllCertsPolicy : ICertificatePolicy {
        public bool CheckValidationResult(
            ServicePoint srvPoint, X509Certificate certificate,
            WebRequest request, int certificateProblem) {
            return true;
        }
    }
"@
[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy

$hdrs = @{}
$hdrs.Add("Authorization","Bearer &lt;STRONG&gt;eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...3TOMbQPF2gCb5xnzB9mKumqldotYBH_2OjKZakYHQzNTRzMNRoH5eG6UovkPBA&lt;/STRONG&gt;")
$url = "https://&lt;STRONG&gt;nprinting01.domain.local&lt;/STRONG&gt;:4993/api/v1/connections"
Invoke-RestMethod -Uri $url -Method Get -ContentType 'application/json' -Headers $hdrs | ConvertTo-Json -Depth 10&lt;/PRE&gt;
&lt;P data-unlink="true"&gt;&lt;BR /&gt;For information about running script in PowerShell see&amp;nbsp;&lt;I&gt;&lt;U&gt;&lt;A href="https://community.qlik.com/t5/Official-Support-Articles/Qlik-Sense-QRS-API-using-Xrfkey-header-in-PowerShell/ta-p/1716660" target="_blank" rel="noopener"&gt;Qlik Sense QRS API using Xrfkey header in PowerShell&lt;/A&gt;&lt;/U&gt;&lt;/I&gt;&lt;/P&gt;
&lt;BLOCKQUOTE class="quote"&gt;This&amp;nbsp;custom solution is limited to NPrinting API's only and does not apply to Qlik Sense and NPrinting On Demand reporting (NPrinting On Demand with Qlik Sense support NTLM only. JWT is not supported for use with supported Qlik Sense NPrinting On Demand report objects)&lt;/BLOCKQUOTE&gt;</description>
    <pubDate>Thu, 21 Mar 2024 09:37:11 GMT</pubDate>
    <dc:creator>Damien_V</dc:creator>
    <dc:date>2024-03-21T09:37:11Z</dc:date>
    <item>
      <title>NPrinting: How to configure and call APIs with JWT authentication</title>
      <link>https://community.qlik.com/t5/Official-Support-Articles/NPrinting-How-to-configure-and-call-APIs-with-JWT-authentication/ta-p/1712523</link>
      <description>&lt;P&gt;This explains how to set up JWT authentication to call the NPrinting API.&lt;/P&gt;
&lt;BLOCKQUOTE class="quote"&gt;This customization is provided as is. Qlik Support cannot provide continued support of the solution. For assistance, reach out to our &lt;A href="https://community.qlik.com/t5/Official-Support-Articles/How-and-when-to-contact-Qlik-s-Professional-Services-and/ta-p/1714936" target="_blank" rel="noopener"&gt;Professional Services&lt;/A&gt; or engage in our active &lt;A href="https://community.qlik.com/t5/Integration-Extension-APIs/bd-p/qlik-sense-integration-extension-api" target="_blank" rel="noopener"&gt;Integrations forum&lt;/A&gt;.&lt;/BLOCKQUOTE&gt;
&lt;P&gt;If you do not have a certificate, for testing purposes, it is possible to use certificates generated by default by NPrinting in&amp;nbsp;C:\ProgramData\NPrinting\certificates:&lt;/P&gt;
&lt;P&gt;cert.pem&lt;BR /&gt;key.pem&lt;BR /&gt;&lt;BR /&gt;For production environments, for security purposes, we recommend that you use a certificate you have purchased or generated yourself.&lt;/P&gt;
&lt;H4&gt;&lt;FONT color="#339966"&gt;&lt;STRONG&gt;Setting up JWT authentication in the NPrinting Console&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/H4&gt;
&lt;OL&gt;
&lt;LI&gt;Go to Admin &amp;gt; Settings &amp;gt; Authentication&lt;/LI&gt;
&lt;LI&gt;Select "Enabled" for JWT authentication&lt;/LI&gt;
&lt;LI&gt;Open cert.pem in a text editor, copy the content and paste it in JWT certificate&lt;/LI&gt;
&lt;LI&gt;Choose "Authenticate user by email" and input a value for the attributes name, such as "mailaddress" (Authenticate user by Domain\Name can also be used if the user has a domain account filled in in his user information)&lt;/LI&gt;
&lt;LI&gt;Click on "Update authentication settings" in order to save.&lt;/LI&gt;
&lt;/OL&gt;
&lt;H4&gt;&lt;FONT color="#339966"&gt;&lt;STRONG&gt;Generate a JWT token&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/H4&gt;
&lt;P&gt;It is possible to use the debugger on &lt;A href="https://jwt.io" target="_blank" rel="noopener"&gt;https://jwt.io&lt;/A&gt; in order to generate a JWT token.&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Select algorithm: RS256&lt;/LI&gt;
&lt;LI&gt;In Payload, input the following:
&lt;PRE&gt;{
  "mailaddress":"&lt;STRONG&gt;youremailaddress@email.com&lt;/STRONG&gt;"
}&lt;/PRE&gt;
The email address should be the email address of an NPrinting user.&lt;BR /&gt;&amp;nbsp;&lt;/LI&gt;
&lt;LI&gt;In "Verify signature", paste the content of cert.pem in the first field and the content of key.pem in the second field.&lt;/LI&gt;
&lt;LI&gt;The JWT token is now ready to use and appear on the left.&lt;/LI&gt;
&lt;/OL&gt;
&lt;H4&gt;&lt;FONT color="#339966"&gt;&lt;STRONG&gt;Use the JWT token to call the NPrinting API:&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/H4&gt;
&lt;P&gt;Below is a PowerShell script that is calling the API using JWT authentication. The JWT token needs to be passed in the "Authorization" header and be preceded by the "Bearer" keyword, the same method can also be used in the Qlik Rest Connector or Postman.&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

add-type @"
    using System.Net;
    using System.Security.Cryptography.X509Certificates;
    public class TrustAllCertsPolicy : ICertificatePolicy {
        public bool CheckValidationResult(
            ServicePoint srvPoint, X509Certificate certificate,
            WebRequest request, int certificateProblem) {
            return true;
        }
    }
"@
[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy

$hdrs = @{}
$hdrs.Add("Authorization","Bearer &lt;STRONG&gt;eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...3TOMbQPF2gCb5xnzB9mKumqldotYBH_2OjKZakYHQzNTRzMNRoH5eG6UovkPBA&lt;/STRONG&gt;")
$url = "https://&lt;STRONG&gt;nprinting01.domain.local&lt;/STRONG&gt;:4993/api/v1/connections"
Invoke-RestMethod -Uri $url -Method Get -ContentType 'application/json' -Headers $hdrs | ConvertTo-Json -Depth 10&lt;/PRE&gt;
&lt;P data-unlink="true"&gt;&lt;BR /&gt;For information about running script in PowerShell see&amp;nbsp;&lt;I&gt;&lt;U&gt;&lt;A href="https://community.qlik.com/t5/Official-Support-Articles/Qlik-Sense-QRS-API-using-Xrfkey-header-in-PowerShell/ta-p/1716660" target="_blank" rel="noopener"&gt;Qlik Sense QRS API using Xrfkey header in PowerShell&lt;/A&gt;&lt;/U&gt;&lt;/I&gt;&lt;/P&gt;
&lt;BLOCKQUOTE class="quote"&gt;This&amp;nbsp;custom solution is limited to NPrinting API's only and does not apply to Qlik Sense and NPrinting On Demand reporting (NPrinting On Demand with Qlik Sense support NTLM only. JWT is not supported for use with supported Qlik Sense NPrinting On Demand report objects)&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Thu, 21 Mar 2024 09:37:11 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Official-Support-Articles/NPrinting-How-to-configure-and-call-APIs-with-JWT-authentication/ta-p/1712523</guid>
      <dc:creator>Damien_V</dc:creator>
      <dc:date>2024-03-21T09:37:11Z</dc:date>
    </item>
    <item>
      <title>Re: NPrinting: How to configure and call APIs with JWT authentication</title>
      <link>https://community.qlik.com/t5/Official-Support-Articles/NPrinting-How-to-configure-and-call-APIs-with-JWT-authentication/tac-p/2430448#M13495</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/29425"&gt;@Damien_V&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;any possibility to use AD groups instead of AD users?&lt;/P&gt;
&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Wed, 13 Mar 2024 16:36:27 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Official-Support-Articles/NPrinting-How-to-configure-and-call-APIs-with-JWT-authentication/tac-p/2430448#M13495</guid>
      <dc:creator>petrus</dc:creator>
      <dc:date>2024-03-13T16:36:27Z</dc:date>
    </item>
  </channel>
</rss>

