cups-ipp icon indicating copy to clipboard operation
cups-ipp copied to clipboard

Request Unauthorized

Open kasperdeboerdev opened this issue 6 years ago • 4 comments

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?

kasperdeboerdev avatar Jun 06 '18 12:06 kasperdeboerdev

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).

slawkens avatar Jun 06 '18 13:06 slawkens

Never thought about it. It works now. Thanks!

kasperdeboerdev avatar Jun 06 '18 13:06 kasperdeboerdev

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

TechnicalSuwako avatar Nov 22 '19 09:11 TechnicalSuwako

The URI seemed wrong. Once corrected, I was able to(´・ω・`)

TechnicalSuwako avatar Nov 25 '19 08:11 TechnicalSuwako