We will cover how to implement Google, Twitter, GitHub, Facebook & Many Other Social Generic Logins With PHP Laravel Socialite. This package is really awesome for all social logins.

We will cover the following

  1. Laravel Installation
  2. Socialite Package Downloading
  3. Get OAuth Tokens
  4. Database Users Table Setup
  5. Setting Up OAuth Details For Laravel Socialite
  6. Route Setup For All Social Logins
  7. Controller Code For Calling Any Social Authentication Website
  8. Controller Code For Callback From Any Social Website

Step 1 - Laravel Installation

If you have already setup Laravel then skip to the next step. Let’s install Laravel application with the composer.

composer create-project --prefer-dist laravel/laravel socialite_testing

If you would like to learn more on the composer have written an article on it @ What Is Composer? How Does It Work? Useful Composer Commands And Usage


Step 2 - Socialite Package Downloading

For working with any social login we are having a cool official package from Laravel Socialite. Let’s integrate it on our project using composer with the following command

composer require laravel/socialite

Step 3 - Get OAuth Tokens

I have written other articles which cover how to get the OAuth Tokens step by step. Kindly check the articles in the following links

Facebook Login With PHP Laravel Socialite

GitHub Login With PHP Laravel Socialite

The above process remains standard and all you need to do is go and collect the OAuth keys.


Step 4 - Database Setup For Users

Basically we need to store the **Provider Type** and **Provider Auth Token** in our database so that we can verify the user for later usage

Users Migration

Schema::create('users', function (Blueprint $table) {
    $table->bigIncrements('id');
    $table->string('provider_type')->nullable()->comment('Social Account Type');
    $table->string('provider_token')->nullable()->comment('Social Account Token');
    $table->string('name');
    $table->string('password')->nullable();
    $table->string('forgot_password')->nullable();
    $table->string('email');
    $table->string('phone')->nullable();
    $table->boolean('is_blocked')->default(0);
    $table->softDeletes();
    $table->timestamps();
});

#laravel

GitHub Login With PHP Laravel Socialite - Morioh
1.20 GEEK