Archie  Clayton

Archie Clayton


Login with Google in Laravel 5.8 App using Socialite Package

In this tutorial, i would like to share with you how to login with google account using socialite package in laravel 5.8 app. we can easily sign in and signup with google gmail account in laravel 5.8. we will use google authentication for login in laravel 5.8.

If you want to create login with google account then you can do it easily using laravel socialite composer package. If you use other php framework then it difficult to make login with google. But Laravel provide socialite so you can so it quickly. You just need to create secret, app id from google api console.

Just follow few steps to done login with google account example:

Step 1: Install Laravel 5.8

In this step, if you haven’t laravel 5.8 application setup then we have to get fresh laravel 5.8 application. So run bellow command and get clean fresh laravel 5.8 application.

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

Step 2: Install Socialite Package

In first step we will install Socialite Package that provide fb api to connect with google account. So, first open your terminal and run bellow command:

composer require laravel/socialite

After install above package we should add providers and aliases in config file, Now open config/app.php file and add service provider and aliase

'providers' => [




'aliases' => [


    'Socialite' => Laravel\Socialite\Facades\Socialite::class,


Step 3: Create Google App

In this step we need google client id and secret that way we can get information of other user. so if you don’t have google app account then you can create from here : Google Developers Console. you can find bellow screen :

Login with Google in Laravel 5.8 App using Socialite Package

Now you have to click on Credentials and choose first option oAuth and click Create new Client ID button. now you can see following slide:

Login with Google in Laravel 5.8 App using Socialite Package

after create account you can copy client id and secret.

Now you have to set app id, secret and call back url in config file so open config/services.php and set id and secret this way:


return [
    'google' => [
        'client_id' => 'app id',
        'client_secret' => 'add secret',
        'redirect' => 'http://learnl52.hd/auth/google/callback',

Step 4: Add Database Column

In this step first we have to create migration for add google_id in your user table. So let’s run bellow command:

php artisan make:migration add_google_id_column


use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class AddGoogleIdColumn extends Migration
     * Run the migrations.
     * @return void
    public function up()
        Schema::table('users', function ($table) {
     * Reverse the migrations.
     * @return void
    public function down()

Update mode like this way:


namespace App;
use Illuminate\Notifications\Notifiable;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;
class User extends Authenticatable
    use Notifiable;
     * The attributes that are mass assignable.
     * @var array
    protected $fillable = [
        'name', 'email', 'password', 'google_id'
     * The attributes that should be hidden for arrays.
     * @var array
    protected $hidden = [
        'password', 'remember_token',
     * The attributes that should be cast to native types.
     * @var array
    protected $casts = [
        'email_verified_at' => 'datetime',

Step 5: Create Routes

After adding google_id column first we have to add new route for google login. so let’s add bellow route in routes.php file.


Route::get('google', function () {
    return view('googleAuth');
Route::get('auth/google', 'Auth\LoginController@redirectToGoogle');
Route::get('auth/google/callback', 'Auth\LoginController@handleGoogleCallback');

Step 6: Update Controller File

After add route, we need to add method of google auth that method will handle google callback url and etc, first put bellow code on your LoginController.php file.


namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
use Socialite;
use Auth;
use Exception;
use App\User;
class LoginController extends Controller
    | Login Controller
    | This controller handles authenticating users for the application and
    | redirecting them to your home screen. The controller uses a trait
    | to conveniently provide its functionality to your applications.
    use AuthenticatesUsers;
     * Where to redirect users after login.
     * @var string
    protected $redirectTo = '/home';
     * Create a new controller instance.
     * @return void
    public function __construct()
    public function redirectToGoogle()
        return Socialite::driver('google')->redirect();
    public function handleGoogleCallback()
        try {
            $user = Socialite::driver('google')->user();
            $finduser = User::where('google_id', $user->id)->first();
                return return redirect('/home');
                $newUser = User::create([
                    'name' => $user->name,
                    'email' => $user->email,
                    'google_id'=> $user->id
                return redirect()->back();
        } catch (Exception $e) {
            return redirect('auth/google');

Step 7: Create Blade File

Ok, now at last we need to add blade view so first create new file googleAuth.blade.php file and put bellow code:


<!DOCTYPE html>
    <title>Laravel 5.8 Login with Google Account Example</title>
    <div class="container">
       <div class="row">
         <div class="col-md-12 row-block">
          <a href="{{ url('auth/google') }}" class="btn btn-lg btn-primary btn-block">
          <strong>Login With Google</strong>

Ok, now you are ready to use open your browser and check here : URL + ‘/google’.

I hope it can help you…

#laravel #php

What is GEEK

Buddha Community

Login with Google in Laravel 5.8 App using Socialite Package

Basem Ovic


may u help me make it just by api

Laravel 8 Socialite Login with Google Account

Hello Guys,

Today I will share laravel 8 socialite login with google account. In this post give you example of laravel 8 socialite login with google account and also you can knowledge about how to socialite login with google account in laravel 8 jetstream.

This tutorial will give you very easy and simple example of login with gmail in laravel 8.

Read More : Laravel 8 Socialite Login with Google Account

Read More : How To Create Dynamic Pie Chart In Laravel

Read Also : Stripe Payment Gateway Integration Example In Laravel 8

#laravel 8 socialite login with google account #laravel #laravel 8 login with google #login with gmail account #laravel socialite #login with gmail in laravel 8

I am Developer


Laravel 7 Socialite Google Login Example

Laravel 7, 6 socialite google gmail account login example tutorial. Here you will learn how to implement socialite google gmail account login in laravel app using laravel socialite package.

Sometimes, you need to add social login (google, github, facebook, twitter) button in your laravel app for easy login purpose.

This tutorial also provide you live demo of laravel socialite google login app. You can click here “Demo“.

So, This laravel socialite google login example tutorial will help you step by step on how to implement socialite google login in laravel app.

Laravel Socialite Google Login Example

Follow the below and implement socialite google gmail account login in laravel app:

  1. Install laravel App
  2. Add Database Details
  3. Install Socialite Package For Google Login
  4. Create Google App
  5. Set Google App Details
  6. Add Routes
  7. Generate Auth Files By Artisan
  8. Create Controller
  9. Add Socialite Google Login Button In Blade Views
  10. Run Development Server

Read Full post

#google login laravel 7 #laravel socialite google #laravel socialite #laravel login with google account

I am Developer


Laravel 8 Tutorial for Beginners

Hello everyone! I just updated this tutorial for Laravel 8. In this tutorial, we’ll go through the basics of the Laravel framework by building a simple blogging system. Note that this tutorial is only for beginners who are interested in web development but don’t know where to start. Check it out if you are interested: Laravel Tutorial For Beginners

Laravel is a very powerful framework that follows the MVC structure. It is designed for web developers who need a simple, elegant yet powerful toolkit to build a fully-featured website.

Recommended:-Laravel Try Catch

#laravel 8 tutorial #laravel 8 tutorial crud #laravel 8 tutorial point #laravel 8 auth tutorial #laravel 8 project example #laravel 8 tutorial for beginners

I am Developer


Laravel 8 New Features | Release Notes - Tuts Make

In this post, i will show you what’s new in laravel 8 version.

#What’s new in Laravel 8?

  • 1 - Change Path Of Default Models Directory
  • 2 - Removed Controllers Namespace Prefix
  • 3 - Enhancements on php artisan serve
  • 4 - Enhanced Rate Limiting
  • 5 - Enhanced on Route Caching
  • 6 - Update on Pagination Design
  • 8 - Dynamic Blade Componenets
  • 7 - Update Syntax for Closure Based Event Listeners
  • 8 - Queueable Model Event Listeners
  • 9 - Maintenance mode: secret access
  • 10 - Maintenance mode: pre-rendered page
  • 11 - Queued job batching
  • 12 - Queue backoff()
  • 13 - Laravel Factory

#laravel 8 features #laravel 8 release date #laravel 8 tutorial #news - laravel 8 new features #what's new in laravel 8 #laravel 8 release notes

How to Send E-mail Using Queue in Laravel 7/8

Today I will show you How to Send E-mail Using Queue in Laravel 7/8, many time we can see some process take more time to load like payment gateway, email send, etc. Whenever you are sending email for verification then it load time to send mail because it is services. If you don’t want to wait to user for send email or other process on loading server side process then you can use queue.

Read More : How to Send E-mail Using Queue in Laravel 7/8

Read Also : Send Mail Example In Laravel 8

#how to send e-mail using queue in laravel 7/8 #email #laravel #send mail using queue in laravel 7 #laravel 7/8 send mail using queue #laravel 7/8 mail queue example