Laravel 9 Socialite Login with Linkedin Example

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

In this Laravel 9 Login with Linkedin Example Tutorial I’ll show you how to integrate socialite LinkedIn social login in laravel 9 application. In this tutorial you will learn to integrate LinkedIn login in laravel. In this article we will integrate login  with LinkedIn in laravel 9 application.

Laravel 9 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. In this step by step tutorial, you will learn to integrate linkedin login with your laravel 9 application.

Laravel 9 Socialite Login with Linkedin Example

This tutorial is step by step guide for you on how to integrate linkedin social login in laravel 9 using socialite package.

Step 1:- create linkedin app by click the following url :- https://www.linkedin.com/developers/apps/new . And create linkedin app.

Step 2:- After successfully create the app set the redirect URL for example :

Step 3:- Finally, you redirect to dashboard by linkedin.com. So you can copy client id and secret from linkedin app dashboard.

  • Install Laravel 9
  • Connecting App to Database
  • Configure the Linkedin App
  • Install Socialite & Configure
  • Add Field In Table Using Migration
  • Install Jetstream Auth
  • Make Routes
  • Create Linkedin Login Controller By Command
  • Integrate Linkedin Login Button In Login Page
  • Start Development Server

Install Laravel 9

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

Connecting App to Database

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.

Configure Linkedin App

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, configure Linkedin app with this laravel app. So, open your laravel Linkedin social login project in any text editor. Then navigate the config directory and open service.php file and add the client id, secret and callback url:

Install Socialite & Configure

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

After Installing ‘socialite’ package, we need to add service provider and alias in config/app.php file as following.

config/app.php

Then add the Facade in config/app.php:

Add Field In Table Using Migration

Now, we will create a migration file to add social login fields using following command:

Now, open the add_social_login_field.php file, which is found inside database/migration directory and add the following code into it:


After successfully add field in database table. Then add fillable property in User.php model, which is found inside app/Models/ directory:


Now, in this step we will create model and migration file. Please run the following command:

Install Jetstream Auth

In this step, install jetstream laravel auth scaffolding package with livewire. We have provided a complete guide in this Laravel 9 Auth Scaffolding using Jetstream Tutorial.

Make 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

Create Linkedin Login Controller By Command

In this step, run the following command to create LinkedinSocialiteController.php file:

Now, go to app/http/controllers directory and open LinkedinSocialiteController.php file in any text editor. Then add the following code into LinkedinSocialiteController.php file:

Integrate Linkedin Login Button In Login Page

In this step, integrate linkedin login button into login.blade.php file. So, open login.blade.php, which is found inside resources/views/auth/ directory:

Start Development Server

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 9 Socialite Login with Linkedin Example and its application with practical example. I hope you will like this tutorial.