[GH-ISSUE #60] QR Codes not working in Laravel 5.4. #29

Closed
opened 2026-02-25 20:32:13 +03:00 by kerem · 2 comments
Owner

Originally created by @MaverickMartyn on GitHub (May 19, 2017).
Original GitHub issue: https://github.com/antonioribeiro/google2fa/issues/60

I keep getting invalid QR codes when using default settings on Laravel 5.4.
Here is my code:

/**
     * Generate a new 2FA key.
     *
     * @return void
     */
    public function setup2FA(Google2FA $google2fa)
    {
        $user = Auth::user();
        $google2fa_secret = $google2fa->generateSecretKey();
        $google2fa_url = $google2fa->getQRCodeGoogleUrl(
            config('app.name', 'Laravel'),
            $user->email,
            $user->google2fa_secret
        );

        return view('2fa.setup', ['google2fa_secret' => $google2fa_secret, 'google2fa_url' => $google2fa_url]);
    }

I should note that I am using the Microsoft Authenticator app on Windows 10 mobile, but my coworker is having the same issue using Google Authenticator on Android.
Also the Secrets themselves work just fine, if entered manually.
What gives?

Originally created by @MaverickMartyn on GitHub (May 19, 2017). Original GitHub issue: https://github.com/antonioribeiro/google2fa/issues/60 I keep getting invalid QR codes when using default settings on Laravel 5.4. Here is my code: ```php /** * Generate a new 2FA key. * * @return void */ public function setup2FA(Google2FA $google2fa) { $user = Auth::user(); $google2fa_secret = $google2fa->generateSecretKey(); $google2fa_url = $google2fa->getQRCodeGoogleUrl( config('app.name', 'Laravel'), $user->email, $user->google2fa_secret ); return view('2fa.setup', ['google2fa_secret' => $google2fa_secret, 'google2fa_url' => $google2fa_url]); } ``` I should note that I am using the Microsoft Authenticator app on Windows 10 mobile, but my coworker is having the same issue using Google Authenticator on Android. Also the Secrets themselves work just fine, if entered manually. What gives?
kerem closed this issue 2026-02-25 20:32:13 +03:00
Author
Owner

@tonydew commented on GitHub (May 20, 2017):

I'm using this in a brand new test 5.4 projects and it's generating both the getQRCodeGoogleUrl() and getQRCodeInline() QR codes. Of course, to use the latter, you need to composer require "bacon/bacon-qr-code":"~1.0" too.

<!-- gh-comment-id:302851721 --> @tonydew commented on GitHub (May 20, 2017): I'm using this in a brand new test 5.4 projects and it's generating both the `getQRCodeGoogleUrl()` and `getQRCodeInline()` QR codes. Of course, to use the latter, you need to `composer require "bacon/bacon-qr-code":"~1.0"` too.
Author
Owner

@MaverickMartyn commented on GitHub (May 20, 2017):

I figured it out. My mistake. I was tired and missed an error in my code above.
And as you can see from above, I used the Google url variant, and it did generate it just fine.
I just didn't give it the actual secret, because of a mistake in my code.
Closing this issue now.

<!-- gh-comment-id:302894140 --> @MaverickMartyn commented on GitHub (May 20, 2017): I figured it out. My mistake. I was tired and missed an error in my code above. And as you can see from above, I used the Google url variant, and it did generate it just fine. I just didn't give it the actual secret, because of a mistake in my code. Closing this issue now.
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/google2fa#29
No description provided.