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

proxy basic auth #50

Open
arahnale opened this issue Feb 2, 2020 · 3 comments
Open

proxy basic auth #50

arahnale opened this issue Feb 2, 2020 · 3 comments

Comments

@arahnale
Copy link

arahnale commented Feb 2, 2020

Hello. Please tell me how you can use basic authorization (login , password) when

launch_arg => ['--proxy-server=proxy.com']
@Corion
Copy link
Owner

Corion commented Feb 10, 2020

I've never used basic auth with a proxy, but maybe try

launch_arg => ['--proxy-server=http://user:password@proxy.com']

... or try setting the HTTP_PROXY variable before launching Chrome:

$ENV{HTTP_PROXY} = 'http://user:password@proxy.com';
$ENV{HTTPS_PROXY} = 'http://user:password@proxy.com';

my $mech = WWW::Mechanize::Chrome->new(
    ...
    # launch_arg => []
);

@arahnale
Copy link
Author

Thanks, but it didn’t work.
I managed to make authorization through:

launch_arg => ['--proxy-server=http://12.43.56.67:1234'],

...

$chrome->driver->send_packet('Fetch.enable' , 'handleAuthRequests' => JSON::true );

 my $asdf = $chrome->add_listener('Fetch.requestPaused', sub {
   my( $info ) = @_;
   my $requestId = $info->{'params'}{'requestId'};
   $chrome->driver->send_message('Fetch.continueRequest' , 'requestId' => $requestId);
 });

 my $asd = $chrome->add_listener('Fetch.authRequired', sub {
   my( $info ) = @_;
   my $requestId = $info->{'params'}{'requestId'};
   print "Fetch auth\n";
   my %auth = (
     'requestId' => $requestId ,
     "authChallengeResponse" => {"response" => "ProvideCredentials" , "username" => "my_user_name" , "password" => "my_password"});
     my $a = $chrome->driver->send_message('Fetch.continueWithAuth' , %auth);
   });

@skyhighpn
Copy link

skyhighpn commented Sep 21, 2022

@arahnale
I'm trying your code, and it should work from what I can tell, but the Fetch.authRequired just doesn't seem to trigger. It only triggers the Fetch.requestPaused. "Fetch pause" is all that is outputted with a proxy error in chromium. Any suggestions?

 my $asd = $mechtwo->add_listener('Fetch.authRequired', sub {
   my( $info ) = @_;
   print "Fetch auth\n";
   my $requestId = $info->{'params'}{'requestId'};
   my %auth = (
     'requestId' => $requestId ,
     "authChallengeResponse" => {"response" => "ProvideCredentials" , "username" => "" , "password" => ""});
     my $a = $mechtwo->target->send_message('Fetch.continueWithAuth' , %auth);
   });
 my $asdf = $mechtwo->add_listener('Fetch.requestPaused', sub {
   my( $info ) = @_;
   print "Fetch pause\n";
   my $requestId = $info->{'params'}{'requestId'};
  $mechtwo->target->send_message('Fetch.continueRequest' , 'requestId' => $requestId);
 });

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