Laravel 7/6 socialite Github Login Example

In this tutorial you will learn about the Laravel 7/6 socialite Github Login Example and its application with practical example.

In this Login with Github in Laravel 7/6 example tutorial I’ll show you how to integrate Github login in laravel 7/6 using socialite package. Integrating Github login in Laravel 7/6 using socialite package is much easier. 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 7/6 socialite Github Login Example

In this step by step tutorial, you will learn to integrate Github login with your laravel 7/6 application. Please follow the steps give below:

  1. Install Laravel App
  2. Configure Database Detail
  3. Create Github App
  4. Add Github App Detail
  5. Install Socialite Package For Github Login
  6. Add Fillable Property in Model
  7. Add fields Into User Migration File
  8. Run Table Migration Command
  9. Create Auth Files By Artisan
  10. Add Routes
  11. Create Controller
  12. Add Github Auth Button On Laravel View
  13. Start Development Server
  14. Laravel 7, 6 Socialite GitHub Login App Looks Like

Step 1: Install Laravel App

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

Step 2: Configure Database Detail

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.

Step 3: Create Github App

In this step we will create github App for github social login. Use the link provided to create twitter app.

Here you have to click New Auth APP button to Create your app. After this you need to register a new OAuth application page will open. So fill your app detail and submit it, Finally, you will see dashboard of your created github app. Now, copy your github app details.

Step 4: Add Github App Detail

In this step, add GitHub app details into service.php file. Go to config directory and open service.php file. Then add the client id and secret got from github app into service.php file:

Step 5: Add Fillable Property in Model

Now, go to app folder and open User.php Model file update fillable property like following:

app/User.php

Step 6: Add fields Into User Migration File

In this step, go to database/migrations directory and open create_users_table.php file. Then add following code into create_users_table.php file to add some fields into users table

Step 7: Run Table Migration Command

Now, Navigate to app/providers directory and inside this directory find AppServiceProvider.php file and open it in any text editor. Then add the following code in AppServiceProvider.php file:

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

Step 8: Install Socialite Package

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

Step 9: Create Auth Files By Artisan

Install Laravel UI

Create Auth

NPM Install

Step 10: Add 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

Step 11: Create Controller

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

After that, go to app/http/controllers directory and open GithubSocialController.php file. Then put the following code into GithubSocialController.php file:

Step 12: Add Github Auth Button On Laravel View

Now, go to resources/Views/Auth/ directory and open register.blade.php. After that, add the github login button into register.blade.php file:

So, navigate to resources/Views/Auth/ directory and open login.blade.php in any text editor. After that, add the github login button into login.blade.php file:

Step 13: Run 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 7/6 socialite Github Login Example and its application with practical example. I hope you will like this tutorial.