Login with Google in Laravel 10 App using Socialite Package | Add Sign-in with Google feature in Laravel

Posted by

I’m going to learn how to sign up and log in to a Google account using Gmail in this video. Please take the few simple actions listed below. You can log in using Google after following this tutorial.

Step 1: Install Laravel

composer create-project laravel/laravel laravel-google 

Step 2: Go to .env and set up connect with database


Step 3: Migrate table

php artisan migrate

Let’s go to create authentication and run below command

php artisan make:auth

Go to composer.json and paste this version


Now update composer

composer update

add provider in config/app.php file


add alias in config/app.php

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

Next create google App credentials here

if you don’t have google app account then you can create from here : Google Developers Console.

Now OAuth client created successfully.

Go to services.php and put your client id and client secret and callback url

'google' => [
        'client_id' => '346684678449-fbn3ngtcvddprrlmdsjco4kson26nvvi.apps.googleusercontent.com',
        'client_secret' => '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',
        'redirect' => 'https://www.wizbrand.com/auth/google/callback',
php artisan make:model SocialProvider -m

customize migration social_providers

php artisan migrate

add socialProviders() function in user model

go to register controller and paste this code

add routes in web.php

Lets got to User.php and add this function below

function socialProviders()
        return $this->hasMany(SocialProvider::class);

Next go to SocialProvider.php and this function

protected $fillable = ['provider_id','provider'];
     function user()
        return $this->belongsTo(User::class);

Add Login with google Button On Blade File

<button class="btn btn-primary">
       <a class="text-white" href="{{ url('auth/google')}}">Google Login</a>

Now register page look like this and continue with google.

Now continue with google

Now Logged in Successfully…..

Thank you for reaching out. I hope this guide has been extremely useful. If the code is not working properly, please leave a comment below. 🙏🙏

Notify of
Inline Feedbacks
View all comments
Would love your thoughts, please comment.x