Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request Unauthorized #5

Open
kasperdeboerdev opened this issue Jun 6, 2018 · 4 comments
Open

Request Unauthorized #5

kasperdeboerdev opened this issue Jun 6, 2018 · 4 comments

Comments

@kasperdeboerdev
Copy link

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?

@slawkens
Copy link

slawkens commented Jun 6, 2018

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

@kasperdeboerdev
Copy link
Author

Never thought about it. It works now. Thanks!

@TechnicalSuwako
Copy link

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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants