8 months ago

Socialite can't login with google

Posted 8 months ago by silviach

I'm current using Laravel 5.5 and Socialite 2.0 I want to enable user to login via Google and until now I can get user info from google and create new user using the information. However, I can't seem to login with the credential. There is no error message either...Any thoughts? Below is my code

$user = Socialite::driver('google')->user();

$existingUser = User::where('email', $user->email)->first();


} else {
    $newUser                  = new User;
    $newUser->name            = $user->name;
    $newUser->email           = $user->email;
    $newUser->google_id       = $user->id;
    $newUser->avatar          = $user->avatar;
    $newUser->avatar_original = $user->avatar_original;
    Auth::login($newUser, true);

return redirect()->to('/home');

Please sign in or create an account to participate in this conversation.