wstrange / GoogleAuth

Google Authenticator Server side code

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Replacement for Google Charts usage

ukaradhyula opened this issue · comments

Google image charts seems to be deprecated since 2012 and getting permanently shut down on March 14th, 2019

GoogleAuthenticatorQRGenerator.TOTP_URI_FORMAT seems to use this (https://chart.googleapis.com) to generate QR code and will fail to work after March 14th.

Is this issue known and is up to the developers using this library to find an alternative to generate QR code after getting otpauth or are there any plans to update this library with another QR code generator?

In case anyone needs it, qrserver.com will work instead:

private static final String qrCodeGeneratorUrl = "https://api.qrserver.com/v1/create-qr-code/?data=%s&size=150x150";

String authUrl = GoogleAuthenticatorQRGenerator.getOtpAuthTotpURL(issuer, username, key);

try {
    return String.format(qrCodeGeneratorUrl, URLEncoder.encode(authUrl, StandardCharsets.UTF_8.name()));
} catch (UnsupportedEncodingException e) {
    throw new RuntimeException("UTF-8 encoding is not supported by URLEncoder", e);
}
commented

This can be implemented without using any web API with com.google.zxing:core Version 3.4.0

Example code how to generate the QR code can be found here: CalliCoder - Generate QR Code in java using zxing
The version of zxing is a little bit outdated there, but should still work if you replace the version at the maven dependencies.

I've actually arrived to the conclusion that the library should not try to do more than just one thing. I think I'll drop the QR management code ASAP.

Fixed in v. 1.3.0, switching to the QR code API.