Laravel 9 Socialite Google Login Example Tutorial

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

In this Laravel 9 Socialite Google Login Example Tutorial I’ll show you how to integrate google login in laravel 9 using socialite package. Integrating google login in Laravel 9 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 9 Socialite Google Login Example Tutorial

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

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

Install Laravel 8 App

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

Configure Database With App

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 Google App

In this step, we will configure Google app with this laravel app. So, open your laravel Google 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:

Now, Navigate to config directory and open app.php file. Then add aliese and provider app.php:

Then add the Facade in config/app.php:

Add Field In Table Using Migration

Now, we will create migration to add social login field using following command:

After that, 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:


After that, execute the following command on cmd to create tables into your selected database:

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 Google Login Controller By Command

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

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

Integrate Google Login Button In Login Page

In this step, integrate google 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 Google Login Example Tutorial and its application with practical example. I hope you will like this tutorial.