Socialite authentication in Laravel

First thing you have to do is to install socialite in your Laravel project
You can use the following command in terminal

In config\app.php file you need to add following codes for the configurations
under the providers
Laravel\Socialite\SocialiteServiceProvider::class,
under the Alias
'Socialite' => Laravel\Socialite\Facades\Socialite::class

You need to add following two functions for the App\Http\Controllers\Auth\LoginController.php file

In config\service.php file you can add setting for Facebook as shown in the below code

Next, you can add following code to your routes\web.php file

Now you can test the code with URL http://localhost/public/login/facebook/

Related Errors

You may get the following errors when you test with the localhost

To solve this problem you can download the https://curl.haxx.se/ca/cacert.pem and you can copy the files to /Applications/XAMPP/xamppfiles
Then you can update the php.ini file in your server with following entry
curl.cainfo = “/Applications/XAMPP/xamppfiles/cacert.pem”

Leave a Reply

Your email address will not be published. Required fields are marked *