Add Social Login in your Laravel Application

Ramesh Mhetre
fullstackworld
Published in
2 min readFeb 25, 2018

In addition to typical, form-based authentication, Laravel also provides a simple, convenient way to authenticate with OAuth providers using Laravel Socialite. Socialite currently supports authentication with Facebook, Twitter, LinkedIn, Google, GitHub and Bitbucket.

Here are few quick steps to get started social authentication up and running on your site.

Installation

To get started with Socialite, use Composer to add the package to your project’s dependencies:

composer require laravel/socialite

Before using Socialite, you will also need to add credentials for the OAuth services your application utilizes. These credentials should be placed in your config/services.phpconfiguration file, and should use the key facebook, twitter, linkedin, google, githubor bitbucket, depending on the providers your application requires. For example:

'github' => [
'client_id' => env('GITHUB_CLIENT_ID'), // Your GitHub Client ID
'client_secret' => env('GITHUB_CLIENT_SECRET'), // Your GitHub Client Secret
'redirect' => 'http://your-callback-url',
],

Similarly, you need to add required client_id, secrete_key & redirect path in your services.php file for whatever service you need to use for authentication.

To customize for any specific service you can create custom routes & the handle your custom logic in the authentication controller.

All supported adapters & their installation steps are listed here. Those are many adapters with mostly all famous OAuth providers, you can easily create your own provider as well. Here is the link to the official step-by-step guide to creating your own provider.

--

--