This is an archived forum post. The information may be outdated. Contact us if you have any questions.

API V2 setHttpAuth

alparandr wrote on 2019-06-12:
Hello,

I noticed that setHttpAuth method doesn't work. When I try to set username and password, I still get empty string in HTTP_AUTHORIZATION. Maybe I'm doing something wrong, but as I understand I have to get HTTP_AUTHORIZATION on my page using convertUrl method. Am I wrong? Could you please provide and example how to use this method or explain to me what I did wrong?

Alex
support wrote on 2019-06-13:
Hello Alex,

Please mail your source code using Pdfcrowd API to support@pdfcrowd.com
support wrote on 2019-06-14:
Hello Alexander,
?
?It seems that the page you are trying to convert (https://www.example.com/html-generator.php) doesn't support HTTP basic authentication.
?
?Please try the following example. It works fine.
?
?<?php
    require_once("pdfcrowd.php");
    try {
        $client = new \Pdfcrowd\HtmlToPdfClient('demo', 'ce544b6ea52a5621fb9d55f8b542d14d');
        $client->setHttpAuth("guest", "guest"); // settings username and password name to get access to https://jigsaw.w3.org/HTTP/Basic/, see https://jigsaw.w3.org/HTTP/
        $pdf = $client->convertUrl('https://jigsaw.w3.org/HTTP/Basic/');

        // set HTTP response headers
        header("Content-Type: application/pdf");
        header("Cache-Control: max-age=0");
        header("Accept-Ranges: none");
        header("Content-Disposition:inline;filename=\"test.pdf\"");

        echo $pdf;
        exit;
    } catch (PdfcrowdException $err) {
        var_dump($err->getCode());
        var_dump($err->getMessage());
    }

DavidThompson1983 wrote on 2020-12-17:
Sorry I'm trying to find out how I would pass a firebase auth token?