Laravel Socialite Google login failed and returns empty dd()


This Content is from Stack Overflow. Question asked by OsamaTheCoder

I am trying to use Socialite in Laravel to login with Google accounts and Facebook accounts

I installed Socilaite package and added ‘google’ driver to services.php and made all the necessary configurations in the database and the providers and I made the facebook login and it works well, but google is not working well

The functions

public function redirectToGoogle()
    return Socialite::driver('google')->redirect();

public function handleGoogleCallback()
    try {
        $user = Socialite::driver('google')->user();
        $finduser = User::where('social_id', $user->id)->first();
            return redirect(route('home'));
        } else {
            $newUser = User::create([
                'name' => $user->name,
                'email' => $user->email,
                'social_id'=> $user->id,
                'social_type'=> 'google',
                'password' => encrypt('my-google')
            return redirect(route('home'));
    } catch (Exception $e) {

And this is what I get



This question is not yet answered, be the first one who answer using the comment. Later the confirmed answer will be published as the solution.

This Question and Answer are collected from stackoverflow and tested by JTuto community, is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?