Laravel Socialite 与 facebook 登录不一致

问题描述 投票:0回答:0

我有 Laravel/Breeze/InertiaJS/Vue 设置,需要使用 Google 和 Facebook 等 SNS 登录。我可以毫无问题地使用谷歌登录/注销,但在 facebook 上,登录非常不一致。我相信我在 Facebook 开发者应用程序上的设置是正确的,因为我已经能够登录,但并非总是如此。下面是我如何实现回调的代码:

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;
    }
}

问题停在

$socialUser = \Socialite . . .
案例的
facebook
部分。没有堆栈跟踪,页面将返回错误 502。

补充说明:当我无法再通过 facebook 登录时,我也无法访问网络应用程序上的任何页面。将始终返回错误 502。要解决此问题,我需要重新启动我的 docker 容器。

我正在使用 Laravel 9.19、Laravel/Socialite 5.6。我遵循了这篇article中的教程。

laravel facebook laravel-socialite
© www.soinside.com 2019 - 2024. All rights reserved.