phpoptimist phpoptimist -4 years ago 63
PHP Question

Laravel Socialite is not integrating Properly

I have installed Laravel 5.4 and adding laravel Socialite for social logins. the problem is nothing appears on login form. what would be possibly wrong?

The controller I created:

    * Handle Social login request
    * @return response

   public function socialLogin($social)

       return Socialite::driver($social)->redirect();


    * Obtain the user information from Social Logged in.

    * @param $social

    * @return Response


   public function handleProviderCallback($social)


       $userSocial = Socialite::driver($social)->user();

       $user = User::where(['email' => $userSocial->getEmail()])->first();



           return redirect()->action('HomeController@index');


           return view('auth.register',['name' => $userSocial->getName(), 'email' => $userSocial->getEmail()]);



The routes in web.php:



I have updated the view as:

<div class="form-group">

                           <label for="name" class="col-md-4 control-label">Login With</label>

                           <div class="col-md-6">

                               <a href="{{ url('login/facebook') }}" class="btn btn-social-icon btn-facebook"><i class="fa fa-facebook"></i></a>

                               <a href="{{ url('login/twitter') }}" class="btn btn-social-icon btn-twitter"><i class="fa fa-twitter"></i></a>

                               <a href="{{ url('login/google') }}" class="btn btn-social-icon btn-google-plus"><i class="fa fa-google-plus"></i></a>

                               <a href="{{ url('login/linkedin') }}" class="btn btn-social-icon btn-linkedin"><i class="fa fa-linkedin"></i></a>

                               <a href="{{ url('login/github') }}" class="btn btn-social-icon btn-github"><i class="fa fa-github"></i></a>

                               <a href="{{ url('login/bitbucket') }}" class="btn btn-social-icon btn-bitbucket"><i class="fa fa-bitbucket"></i></a>



Answer Source

May be you forgot to add providers and alias for Laravel Socialite.

open app/config.php file and add the following line in providers array.


Now add the following line in aliases array.

'Socialite' => Laravel\Socialite\Facades\Socialite::class,

Try this if it works for you.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download