0

I have a Laravel/Breeze/InertiaJS/Vue setup and need to login using SNS like Google and Facebook. I am able to login/logout with google without any issues but on facebook, login is very inconsistent. I believe my setup is correct on facebook developer apps since I am already able to login, just not always though. Below is my code on how I implemented my callback:

public function callback($social)
{
    \Log::debug(print_r("PROCESSING CALLBACK on SOCIAL: " . $social, true));
    try {
        $socialId = [];
        $profileUpdateOrCreate = [];
        switch ($social) {
            case 'facebook':
                $socialUser = \Socialite::driver($social)
                    ->fields([
                        'name',
                        'first_name',
                        'last_name',
                        'email',
                    ])
                    ->stateless()
                    ->user();

                \Log::debug(print_r($socialUser, true));

                $socialId = [
                    'facebook_id' => $socialUser->getId(),
                ];

                $profileUpdateOrCreate = [
                    'last_name' => $socialUser->user['last_name'],
                    'first_name' => $socialUser->user['first_name'],
                ];
                break;

            case 'google':
                $socialUser = \Socialite::driver($social)
                    ->stateless()
                    ->user();

                \Log::debug(print_r($socialUser, true));

                $socialId = [
                    'google_id' => $socialUser->getId(),
                ];

                $profileUpdateOrCreate = [
                    'last_name' => $socialUser->user['family_name'],
                    'first_name' => $socialUser->user['given_name'],
                ];
                break;

            default:
                # code...
                break;
        }

        . . .
    } catch (\Exception $e) {
        \Log::debug(print_r($e->getMessage(), true));
        throw $e;
    }
}

The problem stops at $socialUser = \Socialite . . . part of the facebook case. There is no stacktrace and page will return error 502.

Additional note: When I am no longer able to login via facebook, I also cannot access any pages on the web app. Will always return error 502. To fix this, I need to restart my docker containers.

I am using Laravel 9.19, Laravel/Socialite 5.6. I followed the tutorial in this article.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.