Working with NReco.PdfGenerator.HtmltoPdfConverter and recently implemented OAuth with Bearer tokens. After implementing and securing my ApiControllers the converter started throwing the following error.
WkHtmlToPdfException: Exit with code 1 due to network error: AuthenticationRequiredError (exit code: 1)
After some snooping I discovered I could add custom header parameters and so I grabbed the bearer token and appended it to the CustomWkHtmlArgs
This is what I have to far.
htmlToPdf.CustomWkHtmlArgs = "-L 0mm -R 0mm -T 5mm -B 0mm --javascript-delay 3000";
FileHandlingModule.deleteFile(savePath);
//Get Auth Token
var accessToken = "Bearer " + Request.Headers.Authorization.Parameter;
htmlToPdf.CustomWkHtmlArgs += " --custom-header Authorization: " + accessToken;
htmlToPdf.GeneratePdfFromFile(purl, null, savePath);
This is what the CustomWkHtmlArgs this is what the args string look like.
-L 0mm -R 0mm -T 5mm -B 0mm --javascript-delay 3000 --custom-header Authorization: Bearer YHE7HJEh_Hk0wazErUK6DIGcCG7-GRDHBEWRA-ju9hewqPk9cjY3zH5MT....
The token has been shortened for brevity. I've tried removing the colon and I still get the AuthRequiredError. Is anyone familiar with passing header auth tokens?