ChristianRiesen / otp

One Time Passwords
MIT License
88 stars 28 forks source link

Deprecation of Google Chart Infographics API #5

Open schinkel-zz opened 9 years ago

schinkel-zz commented 9 years ago

The Google Chart Infographics API is deprecated since 2012 although it is still working there is no guarantee this will continue to work. Maybe you could include an alternative.

Info: https://developers.google.com/chart/infographics/docs/qr_codes

ChristianRiesen commented 9 years ago

Thanks. The api is technically dead (or they might pull the plug any second) but it's still around. I think I will change the helpers so this is split and making a url with it is just one possibility.

I feel that until it's dead, supplying it as a possibility is good, but then I'd like to also have a better (more stable?) one that could be used as a replacement. Do you perhaps know of one?

barryvdh commented 8 years ago

You could generate it inline: https://github.com/Bacon/BaconQrCode

ChristianRiesen commented 8 years ago

The difference is that the qr code here is a url which makes it easy to reuse. I think I'll just remove it and make a note about the deprecated url and point to this library, thanks for the input!

barryvdh commented 8 years ago

You can show the base64 image:

use BaconQrCode\Writer;
use BaconQrCode\Renderer\Image\Png;

$otpauth = self::getKeyUri($type, $label, $secret, $counter, $options);

$renderer = new Png();
$renderer->setWidth($width);
$renderer->setHeight($height);

$writer = new Writer($renderer);
$data = $writer->writeString($otpauth);

return 'data:image/png;base64,' . base64_encode($data);
barryvdh commented 8 years ago

You can just use that URL instead of the google one and add it as img src, should be supported in all modern browsers: http://caniuse.com/#feat=datauri