The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.


WWW::Google::Login - log a mechanize object into Google


    my $mech = WWW::Mechanize::Chrome->new(
        headless => 1,
        data_directory => tempdir(CLEANUP => 1),
        user_agent => 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.39 Safari/537.36+',
    $mech->viewport_size({ width => 480, height => 640 });


    my $login = WWW::Google::Login->new(
        mech => $mech,

    if( $login->is_login_page()) {
        my $res = $login->login(
            user => '',
            password => 'my-secret-password',
            headless => 1

        if( $res->wrong_password ) {
            # ?
        } elsif( $res->logged_in ) {
            # yay
        } else {
            # some other error


This module automates logging in a (Javascript capable) WWW::Mechanize object into Google. This is useful for scraping information from Google applications.

Currently, this module only works in conjunction with WWW::Mechanize::Chrome, but ideally it will evolve to not requiring Javascript or Chrome at all.


    if( $login->is_password_page ) {
        $login->login( user => $user, password => $password );


    if( $login->is_login_page ) {
        $login->login( user => $user, password => $password );




    my $res = $login->login(
        user => '',
        password => 'supersecret',
    if( $res->logged_in ) {
        # yay


API usage

Ideally, this module would switch away from screen scraping to directly automating the API below This would make it possible to switch away from WWW::Mechanize::Chrome to a plain HTTP client like HTTP::Tiny or WWW::Mechanize.

Two-factor authentication

Two-factor authentication is not supported at all.

SEE ALSO - Google Business API

This allows a more direct administration of (business) accounts without screen scraping.


The public repository of this module is


The public support forum of this module is


Max Maischein


Copyright 2016-2018 by Max Maischein


This module is released under the same terms as Perl itself.