cups-ipp
cups-ipp copied to clipboard
Request Unauthorized
When I want to print a pdf I only get unauthorized. Made an question on stackoverflow. https://stackoverflow.com/questions/50719482/ipp-printing-returns-unauthorized Could you help me?
Did you try setting client username and password?
Like this:
$client = new Client('your_username', 'your_password');
For me, it worked on macOS, where your_username was my mac os username and same with password (the password that I use to login on my mac).
Never thought about it. It works now. Thanks!
I'm sorry, but I entered the same username and password of the server, but I got an alert saying "not allowed". Can you tell me how to fix it?
$client = new Client(env('PRINT_USER'), env('PRINT_PASS'));
$builder = new Builder();
$responseParser = new ResponseParser();
$printerManager = new PrinterManager($builder, $client, $responseParser);
$printer = $printerManager->findByUri(env('PRINT_URI'));
$jobManager = new JobManager($builder, $client, $responseParser);
$jobs = $jobManager->getList($printer, false, 0, 'completed');
$filename = "請求書_{$r->id}.pdf";
$data = base64_decode($g->data);
$job = new Job();
$job->setName($filename);
$job->setUserName(env('PRINT_USER'));
$job->setCopies(1);
$job->setPageRanges('1');
$job->addFile('data:application/pdf;base64,'.$g->data);
$job->addAttribute('media', 'A4');
$job->addAttribute('fit-to-page', true);
$result = $jobManager->send($printer, $job);
The alert is:
exception: "Http\Client\Common\Exception\ClientErrorException"
file: "/home/〇〇/〇〇/vendor/php-http/client-common/src/Plugin/ErrorPlugin.php"
line: 72
message: "未許可"
Thanking you in advance
The URI seemed wrong. Once corrected, I was able to(´・ω・`)