bakiperl has asked for the wisdom of the Perl Monks concerning the following question:
Folks,
I need help with WWW::Mechanize to automate a login to a page that uses Duo-Authentication. I am able to load the credentials and login but I need to silently pass the second check using the information that is saved in the cookies by the browser (Chrome or any other browser if necessary). Once this is achieved I should be able to things I was able to do before the implementation of the Duo-Authentication.
This call
Here is what I have so far.
I need help with WWW::Mechanize to automate a login to a page that uses Duo-Authentication. I am able to load the credentials and login but I need to silently pass the second check using the information that is saved in the cookies by the browser (Chrome or any other browser if necessary). Once this is achieved I should be able to things I was able to do before the implementation of the Duo-Authentication.
This call
returns this warning: "Decrypted cookies is not set up at..."$cookie_jar->load($cookie_file);
Here is what I have so far.
#!/usr/bin/perl -w use strict; use Data::Dumper; use WWW::Mechanize; use HTTP::Cookies::Chrome; my $username = '**********'; my $passwd = '*********'; my $cookie_file = 'C:/Users/username/AppData/Local/Google/Chrome/User +Data/Default/Cookies'; #chrome cookies path on windows my $cookie_jar = HTTP::Cookies::Chrome->new( # chrome_safe_storage_password => '***", # I don't know what t +o do here file => $cookie_file, # autosave => 1, # ignore_discard => 0, ); $cookie_jar->load($cookie_file); my $mech = WWW::Mechanize->new( cookie_jar => $cookie_jar, ); #$mech->cookie_jar->scan(sub { print Dumper \@_ }); #print $cookie_jar->as_string; my $uri = URI->new( "https://www.*****.com" ); $mech->get( $uri ); unless ($mech->success) { my $mesg = $mech->response->status_line; print $mesg; goto END; } $mech->set_fields( username => $username, password => $passwd, ); $mech -> submit(); sleep(2); $mech->success() or die "Can't fetch the Requested page"; my @form = ( "formname" ); $mech->form_with_fields( @form ); my $value ='******'; eval {$mech->select('fieldName', $value)}; if ($@ and $@ =~ /Illegal value/) { print "This page has not been loaded..."; goto END; } END :
Back to
Seekers of Perl Wisdom