ForgotPasswordAgain has asked for the wisdom of the Perl Monks concerning the following question:

We currently use qr_code of Auth::GoogleAuth to generate QR codes for Google Authenticator, but recently found out that the underlying Google Image Charts was deprecated in 2012... (apparently it's periodically shut off to "notify" users of it going away). Anyone know of an easy replacement or have any recommendations?

Replies are listed 'Best First'.
Re: replacement for Auth::GoogleAuth
by Corion (Patriarch) on Apr 09, 2024 at 17:13 UTC

    I think these QR codes are just otpauth:// URLs.

    In a demo of implementing TOTP yourself, I implemented this and now I see that I even released this onto CPAN as Auth::GoogleAuthenticator. The meat of the code is:

    sub registration_qr_code { my ($self, $label, $type) = @_; # if we have an OTP, dislay the QRCode to the user require Imager::QRCode; my $qrcode = Imager::QRCode->new( size => 4, margin => 4, version => 1, level => 'M', casesensitive => 1, ); my $img = $qrcode->plot($self->registration_url($label, $type)); $img->write( data => \my $res, type => 'png' ); $res } sub registration_key { return encode_base32( $_[0]->{secret} ); } sub registration_url { my ($self, $label, $type) = @_; $type ||= 'totp'; $label= uri_escape($label); return "otpauth://$type/$label?secret=" . $self->registration_key }

    You can find the code also on Github

      Looks pretty much like a drop-in replacement, thanks.