Laravel 8 Socialite Login with Linkedin Tutorial Example

In this tutorial you will learn about the Laravel 8 Socialite Login with Linkedin Tutorial Example and its application with practical example.

In this Laravel 8 Socialite Login with Linkedin Tutorial Example I’ll show you how to create LinkedIn login in laravel 8 using socialite. In this tutorial you will learn to integrate LinkedIn login with socialite in laravel. In this article we will create login with linkedin using socialite in laravel 8 application. In this example I will also guide you through the process to integrate login with linkedin using socialite in laravel.

Laravel Socialite Login with LinkedIn

As we all know that users are not much interested in filling up long registration form to register with any application. Allowing users to login with their social media accounts is quick and powerful way to get registered/verified users for your laravel application. Allowing users to login with their social media accounts makes registration/login process much easier, it also encourages more users to register for your application.

Laravel 8 Socialite Login with Linkedin Tutorial Example

In this step by step tutorial I will demonstrate you how to integrate linkedin login with socialite in laravel application. Please follow the instruction given below:

  • Step 1: Set Up Laravel Project
  • Step 2: Make Database Connection
  • Step 3: Install Jetstream Library
  • Step 4: Configure Socialite Pacakage
  • Step 5: Add and Migrate Linkedin Property in Users Table
  • Step 6: Add Linkedin Client ID and Secret
  • Step 7: Prepare Controller
  • Step 8: Define Routes
  • Step 9: Set Up Login View
  • Step 10: Start Laravel App

Set Up Laravel Project

First of all we need to create a fresh laravel project, download and install Laravel 8 using the below command

Make Database Connection

Now, lets create a MySQL database and connect it with laravel application. After creating database we need to set database credential in application’s .env file.

Install Jetstream Library

In this step, install jetstream laravel auth scaffolding package with livewire. Please follow the instruction.

Now run command to generate ready made auth templates:

Next, use command to install required npm packages:


Now, run the migration to create database table using following artisan command:

Configure Socialite Pacakage

In this step we will Install Socialite Package via Composer using following command:

Register socialite classes in config/app.php configuration file as suggested below:

Add and Migrate Linkedin Property in Users Table

In this step we will create a migration file. Please run the following command:

Thereafter add the new table values in the database/migration/add_social_auth_id_field.php file:

Next, open app/Models/User.php file and add new social auth fields within the file:

Finally, execute command to migrate new values into the user tabel:

Add Linkedin Client ID and Secret

In this step, we will create linkedin app for client and secret key, go to following link

Now create linkedin app filling the details and create your linkedin app. After creating the app set the redirect URL. Now, copy the client id and secret from linkedin app dashboard. Now, go to your project config directory and open service.php file. Then add linkedin app details in service.php file as following:

Prepare Controller

Now, lets create a controller named LinkedinController using command given below –

Once the above command executed, it will create a controller file LinkedinController.php in app/Http/Controllers/ directory. Open the LinkedinController.php file and put the following code in it.

app/Http/Controllers/LinkedinController.php

Define Routes

After this, we need to define routes in “routes/web.php” file. Lets open “routes/web.php” file and add the following routes in it.

routes/web.php

Set Up Login View

Now go to views/auth/login.blade.php file and create a login with linkedin button, add the route which allows making the login request:

Start Laravel App

Now we are ready to run our example so lets start the development server using following artisan command –

Now, open the following URL in browser to see the output –

In this tutorial we have learn about the Laravel 8 Socialite Login with Linkedin Tutorial Example and its application with practical example. I hope you will like this tutorial.