google / google-authenticator

Open source version of Google Authenticator (except the Android app)
Apache License 2.0
5.17k stars 966 forks source link

Unable to scan QR Code with iPhone Google Authenticator App #694

Closed rahulguptafullstack closed 4 years ago

rahulguptafullstack commented 4 years ago

I am integrating the 2FA when I scan QR code with android device then working fine and displaying six digit code like "456 4589" and regenerate in every 30 seconds too. But when scan QR code with iPhone device get "Invalid" and for more detail see in attachment. Why this happening I do not know. Please provide solution for this. Iphone_issue

oakwhiz commented 4 years ago

Also having this issue.

oakwhiz commented 4 years ago

I can confirm that removing any spaces from the URL resolves the issue for me. Perhaps this could be fixed in the app to escape or parse spaces correctly.

rahulguptafullstack commented 4 years ago

Hello everyone, Finally I resolved my issue on same day of issue create. Sorry for late reply. Finally I came with solution that everyone can get solve their issue. Actually I am using a library in PHP for google 2FA authentication. PHPGangsta

Solution: Please do not put any space, hyphen between words in QR code title. You can use underscore.

`<?php require_once 'PHPGangsta/GoogleAuthenticator.php';

$ga = new PHPGangsta_GoogleAuthenticator(); $secret = $ga->createSecret(); $qrCodeUrl = $ga->getQRCodeGoogleUrl('Team_Of_Developers', $secret); echo "Google Charts URL for the QR-Code: ".$qrCodeUrl."\n\n"; ?>`

As in above code snippet I had pass first parameter with underscore(Team_Of_Developers), this will work fine but if you put space like (Team Of Developers) or hyphen(Team-Of-Developers) will not work. Hope this help to everyone.