public function getCallback(Request $request) { $client = $this->google->getClient(); $client->authenticate($_GET['code']); $token = $client->getAccessToken(); $request->session()->put('access_token', $token); $profile = $this->google->getProfile(); $user = $this->userRepository->createOrUpdate($profile, $token); Auth::login($user); return redirect('/')->with('message', 'Successfully logged in with Google.'); }